aboutsummaryrefslogtreecommitdiff
path: root/captain/gemini.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-04-09 08:09:20 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-04-09 08:09:20 -0400
commit025b5d1dcbb30e727afee3307d49328432bae603 (patch)
tree49ad0f24b7f71d9e15fbe03499b1bbaa94e6571c /captain/gemini.f90
parent29ab398f73c791f9591674c813c47267c524e6be (diff)
downloadlevitating-025b5d1dcbb30e727afee3307d49328432bae603.tar.gz
levitating-025b5d1dcbb30e727afee3307d49328432bae603.zip
Modified how logging works so that multiple processes can write in theory.
Diffstat (limited to 'captain/gemini.f90')
-rw-r--r--captain/gemini.f9042
1 files changed, 21 insertions, 21 deletions
diff --git a/captain/gemini.f90 b/captain/gemini.f90
index 02b57c7..099a81e 100644
--- a/captain/gemini.f90
+++ b/captain/gemini.f90
@@ -86,7 +86,7 @@ contains
write(int_text, '(I8)') code
line = trim(adjustl(int_text))//" "//trim(meta)
- call write_log("Status line: '"//trim(line)//"'")
+ call write_log("Status line: '"//trim(line)//"'", LOG_DEBUG)
call write_string(ssl, trim(line)//c_carriage_return//c_new_line)
@@ -179,7 +179,7 @@ contains
use iso_fortran_env
use external_handling, only: external_request_gemini
use api_handling
- use logging, only: write_log
+ use logging
use server_response
implicit none
@@ -206,7 +206,7 @@ contains
ctx = ctx_new(method)
if(.not. C_ASSOCIATED(ctx)) then
- call write_log("Context failed")
+ call write_log("Context failed", LOG_NORMAL)
return
end if
@@ -214,61 +214,61 @@ contains
!res = ctx_set_ecdh_auto(ctx, 1)
if(.not. ctx_use_certificate_file(ctx, trim(pubcert), SSL_FILETYPE_PEM)) then
- call write_log("Cert file failed")
- call write_log("Public: "//trim(pubcert))
+ call write_log("Cert file failed", LOG_NORMAL)
+ call write_log("Public: "//trim(pubcert), LOG_NORMAL)
!call print_error()
return
end if
if(.not. ctx_use_private_key_file(ctx, trim(privcert), SSL_FILETYPE_PEM)) then
- call write_log("Cert file failed")
- call write_log("Private: "//trim(privcert))
+ call write_log("Cert file failed", LOG_NORMAL)
+ call write_log("Private: "//trim(privcert), LOG_NORMAL)
!call print_error()
return
end if
ssl = ssl_new(ctx)
- call write_log("Initiating connection")
+ call write_log("Initiating connection", LOG_DEBUG)
! So this is a GNU Extension...
res = set_read_fd(ssl, fnum(input_unit))
if(res /= 1) then
- call write_log("set rfd failed")
+ call write_log("set rfd failed", LOG_NORMAL)
!call print_error()
return
end if
res = set_write_fd(ssl, fnum(output_unit))
if(res /= 1) then
- call write_log("set wfd failed")
+ call write_log("set wfd failed", LOG_NORMAL)
!call print_error()
return
end if
res = ssl_accept(ssl)
if(res <= 0) then
- call write_log("ssl_accept failed")
+ call write_log("ssl_accept failed", LOG_NORMAL)
!call print_error()
return
end if
- call write_log("Handling read_request")
+ call write_log("Handling read_request", LOG_DEBUG)
! Do the actual protocol nonsense
call read_request(ssl, text_request)
- call write_log("Initializing object")
+ call write_log("Initializing object", LOG_DEBUG)
call req%init(text_request)
- call write_log("Request object created")
+ call write_log("Request object created", LOG_DEBUG)
call req%path_component(1, first)
if(trim(first) == 'api') then
- call write_log("API call encountered")
+ call write_log("API call encountered", LOG_DEBUG)
if(req%protocol == "gemini") then
resp = api_request_gemini(req)
- call write_log("resp filename is: '"//trim(resp%body_filename)//"'")
+ call write_log("resp filename is: '"//trim(resp%body_filename)//"'", LOG_DEBUG)
else if(req%protocol == "titan") then
call treq%init_from_request(req, ssl)
resp = api_request_titan(treq)
@@ -277,7 +277,7 @@ contains
resp = external_request_gemini(req)
end if
- call write_log("Handling response")
+ call write_log("Handling response", LOG_DEBUG)
! Handle the response
select case(resp%code)
case(GEMINI_CODE_INPUT)
@@ -290,21 +290,21 @@ contains
call write_failure(ssl)
case(GEMINI_CODE_SUCCESS)
- call write_log("Sending '"//trim(resp%body_filename)//"' as "//trim(resp%body_mimetype))
+ call write_log("Sending '"//trim(resp%body_filename)//"' as "//trim(resp%body_mimetype), LOG_DEBUG)
open(newunit=rendered_unit, file=resp%body_filename, status="old", &
form="unformatted", iostat=ioerror, access="stream")
call write_file(ssl, rendered_unit, resp%body_mimetype)
- call write_log("File written")
+ call write_log("File written", LOG_DEBUG)
close(rendered_unit)
end select
- call write_log("Cleanup")
+ call write_log("Cleanup", LOG_DEBUG)
call req%destroy()
call resp%destroy()
- call write_log("shutdown")
+ call write_log("Shutdown", LOG_DEBUG)
res = ssl_shutdown(ssl)
res = ssl_free(ssl)
res = ctx_free(ctx)