Add some Log features and bugfixes

This commit is contained in:
René Linder 2021-05-25 10:05:41 +02:00
parent c55ae778fa
commit ed0174b29f
5 changed files with 50 additions and 15 deletions

@ -1 +1 @@
Subproject commit 606f5159d4c3e4c2c9b0c9c6a0f88550cca89951 Subproject commit 7ab2255ff01ce1417093e4e12c8b5e844324c556

View file

@ -47,10 +47,16 @@ Module lhs_web
enable.i enable.i
EndStructure EndStructure
Structure log_config
Accesslog.s
Errorlog.s
EndStructure
Structure server Structure server
http.server_http http.server_http
https.server_https https.server_https
cache.server_cache cache.server_cache
log.log_config
version.s version.s
identifikation.s identifikation.s
defaultfile.s defaultfile.s
@ -236,6 +242,10 @@ Module lhs_web
Procedure set_config(parameter.i=#conf_defaultfile, setting.s="index.html") Procedure set_config(parameter.i=#conf_defaultfile, setting.s="index.html")
Select parameter Select parameter
Case #conf_log_Accesslog
configuration\log\Accesslog = setting
Case #conf_log_Errorlog
configuration\log\Errorlog = setting
Case #conf_HTTP_port Case #conf_HTTP_port
configuration\http\port = Val(setting) configuration\http\port = Val(setting)
Case #conf_HTTPS_Port Case #conf_HTTPS_Port
@ -544,6 +554,15 @@ Module lhs_web
;lhs_log::Out("JSONString:"+ JSONStringToMap) ;lhs_log::Out("JSONString:"+ JSONStringToMap)
thread_type = "" thread_type = ""
If configuration\log\Accesslog <> ""
If m_clients(Str(thread_cli_id))\client_type = #client_HTTPS
lhs_log_ext::Out(configuration\log\Accesslog, lsocket::GetSocketIP(ltls::GetSocket(thread_cli_id)) + " " + Header(#http_head_method) + " " + Header(#http_head_request))
Else
lhs_log_ext::Out(configuration\log\Accesslog, lsocket::GetSocketIP(thread_cli_id) + " " + Header(#http_head_method) + " " + Header(#http_head_request))
EndIf
EndIf
Select Header(#http_head_method) Select Header(#http_head_method)
Case #http_method_get Case #http_method_get
;******************************** ;********************************

View file

@ -8,12 +8,12 @@
<section name="data"> <section name="data">
<explorer view="../../../bin/purebasic/examples/" pattern="0"/> <explorer view="../../../bin/purebasic/examples/" pattern="0"/>
<log show="1"/> <log show="1"/>
<lastopen date="2021-05-22 11:19" user="renlin" host="localhost.localdomain"/> <lastopen date="2021-05-24 22:01" user="renlin" host="linux-3z3y"/>
</section> </section>
<section name="files"> <section name="files">
<file name="inc/lweb_file_cache.pbi"> <file name="inc/lweb_file_cache.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/>
<fingerprint md5="5576f4e31d3d1bc12506fabdc5a2fb66"/> <fingerprint md5="46864140ab7bcff85ebd199d13f4584b"/>
</file> </file>
<file name="inc/lweb_file_cache_header.pbi"> <file name="inc/lweb_file_cache_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="0" panelstate="+-"/>
@ -29,7 +29,7 @@
</file> </file>
<file name="inc/lweb_http.pbi"> <file name="inc/lweb_http.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/>
<fingerprint md5="7812984bb6c4bb774cdb01a35588fe2f"/> <fingerprint md5="e8efea69d459079a6afb3454e20a3b93"/>
</file> </file>
<file name="inc/lweb_http_header.pbi"> <file name="inc/lweb_http_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/>
@ -49,7 +49,7 @@
</file> </file>
<file name="lhs_lib/SYS/lhs_log_ext.pbi"> <file name="lhs_lib/SYS/lhs_log_ext.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+--"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+--"/>
<fingerprint md5="f015019624b5fc7e88221c5d0c122b31"/> <fingerprint md5="e71a63777923aebca7171593016d9b8f"/>
</file> </file>
<file name="lhttpd.pb"> <file name="lhttpd.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
@ -57,7 +57,7 @@
</file> </file>
<file name="lsocket.pbi"> <file name="lsocket.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="d2c7068cbef9e8086aafb98f73905905"/> <fingerprint md5="be7d2d564a84dfe303c8e59c7ec78878"/>
</file> </file>
<file name="ltls.pbi"> <file name="ltls.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
@ -65,15 +65,15 @@
</file> </file>
<file name="lweb.pbi"> <file name="lweb.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="985d9d6bae18494533ca4ef51ae62645"/> <fingerprint md5="4d4c182994443de2dffc808a941bbfa3"/>
</file> </file>
<file name="lweb_header.pbi"> <file name="lweb_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="8d10080da88196da4c3b9966c56d497a"/> <fingerprint md5="33f134da4f3fefc97231572147d3be64"/>
</file> </file>
<file name="server_example.pb"> <file name="server_example.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="7c546da941de1600c939a645628a7f8d"/> <fingerprint md5="5c49bb34e4235b4ca2d10b87ca4777f4"/>
</file> </file>
</section> </section>
<section name="targets"> <section name="targets">
@ -83,12 +83,14 @@
<executable value="server_example"/> <executable value="server_example"/>
<options thread="1" xpskin="1" debug="1"/> <options thread="1" xpskin="1" debug="1"/>
<format exe="console" cpu="0"/> <format exe="console" cpu="0"/>
<debugger custom="1" type="standalone"/>
</target> </target>
<target name="lhttpd" enabled="1" default="0"> <target name="lhttpd" enabled="1" default="0">
<inputfile value="lhttpd.pb"/> <inputfile value="lhttpd.pb"/>
<outputfile value="lhttpd"/> <outputfile value="lhttpd"/>
<executable value="lhttpd"/> <executable value="lhttpd"/>
<options thread="1"/> <options thread="1"/>
<debugger custom="1" type="standalone"/>
</target> </target>
</section> </section>
</project> </project>

View file

@ -39,6 +39,8 @@ DeclareModule lhs_web
#conf_HTTPS_Port #conf_HTTPS_Port
#conf_HTTPS_Binding #conf_HTTPS_Binding
#conf_HTTPS_Enable #conf_HTTPS_Enable
#conf_log_Errorlog
#conf_log_Accesslog
EndEnumeration EndEnumeration
Enumeration cli_handler 1 Enumeration cli_handler 1

View file

@ -24,7 +24,7 @@ XIncludeFile "lweb.pbi"
;* ;*
Define counter, v_lweb_srv_stop Define counter, v_lweb_srv_stop
Define Accesslog.s Define Accesslog.s, Errorlog.s
;* ;*
;* Basic Debug Log initialization: ;* Basic Debug Log initialization:
@ -41,16 +41,26 @@ lhs_log::Init()
;* Enable extended Logging: ;* Enable extended Logging:
;* ;*
Accesslog = lhs_log_ext::Create("Accesslog") Accesslog = lhs_log_ext::Create("Accesslog")
Errorlog = lhs_log_ext::Create("Errorlog")
lhs_log::Out("Errorlog UUID:"+Errorlog)
lhs_log::Out("Accesslog UUID:"+Accesslog)
lhs_log_ext::SetLogFile(Accesslog, "http-s_access.log")
lhs_log_ext::SetLogFile(Errorlog, "http-s_error.log")
lhs_log_ext::Init(Accesslog)
lhs_log_ext::Init(Errorlog)
lhs_web::set_config(lhs_web::#conf_HTTP_port, "8081") lhs_web::set_config(lhs_web::#conf_log_Accesslog, Accesslog)
lhs_web::set_config(lhs_web::#conf_log_Errorlog, ErrorLog)
lhs_web::set_config(lhs_web::#conf_HTTP_port, "8084")
;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1") ;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1")
lhs_web::set_config(lhs_web::#conf_HTTP_binding, "0.0.0.0") lhs_web::set_config(lhs_web::#conf_HTTP_binding, "0.0.0.0")
lhs_web::set_config(lhs_web::#conf_HTTPS_CA, "fullchain.pem") lhs_web::set_config(lhs_web::#conf_HTTPS_CA, "fullchain.pem")
lhs_web::set_config(lhs_web::#conf_HTTPS_Cert, "cert.pem") lhs_web::set_config(lhs_web::#conf_HTTPS_Cert, "cert.pem")
lhs_web::set_config(lhs_web::#conf_HTTPS_Key, "privkey.pem") lhs_web::set_config(lhs_web::#conf_HTTPS_Key, "privkey.pem")
lhs_web::set_config(lhs_web::#conf_HTTPS_Key_Pass, "") lhs_web::set_config(lhs_web::#conf_HTTPS_Key_Pass, "")
lhs_web::set_config(lhs_web::#conf_HTTPS_Binding, "127.0.0.1") lhs_web::set_config(lhs_web::#conf_HTTPS_Binding, "0.0.0.0")
lhs_web::set_config(lhs_web::#conf_HTTPS_Port, "8444") lhs_web::set_config(lhs_web::#conf_HTTPS_Port, "8446")
lhs_web::set_config(lhs_web::#conf_HTTPS_Enable, "1") lhs_web::set_config(lhs_web::#conf_HTTPS_Enable, "1")
lhs_web::set_config(lhs_web::#conf_defaultfile, "/index.html") lhs_web::set_config(lhs_web::#conf_defaultfile, "/index.html")
lhs_web::set_config(lhs_web::#conf_basedir, "/home/renlin/testweb/") lhs_web::set_config(lhs_web::#conf_basedir, "/home/renlin/testweb/")
@ -180,6 +190,8 @@ PrintN("HTTP an Port:"+lhs_web::get_config(lhs_web::#conf_HTTP_port))
PrintN("HTTPS an Port:"+lhs_web::get_config(lhs_web::#conf_HTTPS_Port)) PrintN("HTTPS an Port:"+lhs_web::get_config(lhs_web::#conf_HTTPS_Port))
PrintN("Press Enter to Exit") PrintN("Press Enter to Exit")
Input() Input()
PrintN("Finished")
lhs_log::Close() lhs_log::Close()
lhs_log_ext::StopAllLogger()
PrintN("Finished")
End End