Cachelog added
This commit is contained in:
parent
0c032cfa9d
commit
dc95017cf8
5 changed files with 35 additions and 23 deletions
|
@ -19,10 +19,10 @@ Procedure FileCacheCleaner(Information.i)
|
|||
configuration\cache\current - m_file_cache(MapKey(m_file_cache_map()))\Size
|
||||
FreeMemory(m_file_cache(MapKey(m_file_cache_map()))\Buffer)
|
||||
DeleteMapElement(m_file_cache(), MapKey(m_file_cache_map()))
|
||||
Debug "Info:["+Str(innercount)+"] Killed:["+MapKey(m_file_cache_map())+"]"
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "Info:["+Str(innercount)+"] Killed:["+MapKey(m_file_cache_map())+"]")
|
||||
Selected = DeleteMapElement(m_file_cache_map())
|
||||
Else
|
||||
Debug "Info:["+Str(innercount)+"] Could Not kill:["+MapKey(m_file_cache_map())+"]"
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "Info:["+Str(innercount)+"] Could Not kill:["+MapKey(m_file_cache_map())+"]")
|
||||
EndIf
|
||||
Else
|
||||
Selected = NextMapElement(m_file_cache_map())
|
||||
|
@ -46,7 +46,7 @@ Procedure FileCache(Information.i)
|
|||
|
||||
Repeat
|
||||
WaitSemaphore(file_cache_semaphore)
|
||||
Debug "Adresse:"+m_file_cache()\Buffer
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "Adresse:"+m_file_cache()\Buffer)
|
||||
If (m_file_cache()\Size + configuration\cache\current) <= MaxSize
|
||||
configuration\cache\current + m_file_cache()\Size
|
||||
Tempbuffer = AllocateMemory(m_file_cache()\Size)
|
||||
|
@ -57,7 +57,7 @@ Procedure FileCache(Information.i)
|
|||
m_file_cache_map(MapKey(m_file_cache())) = #True
|
||||
SignalSemaphore(file_cache_semaphore_thread)
|
||||
Else
|
||||
Debug "Cache Full"
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "Cache Full")
|
||||
SignalSemaphore(file_cache_semaphore_thread)
|
||||
EndIf
|
||||
|
||||
|
@ -66,15 +66,15 @@ EndProcedure
|
|||
|
||||
Procedure AddFileToCache(MemoryID.i, FileName.s, Size.i)
|
||||
LockMutex(file_cache_mutex)
|
||||
Debug "Cache MaxSize:"+Str(configuration\cache\maxsize*1024*1024)+" Actual Size:"+Str(configuration\cache\current)
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "Cache MaxSize:"+Str(configuration\cache\maxsize*1024*1024)+" Actual Size:"+Str(configuration\cache\current))
|
||||
m_file_cache(FileName)\Buffer = MemoryID
|
||||
m_file_cache(FileName)\Size = Size
|
||||
SignalSemaphore(file_cache_semaphore)
|
||||
WaitSemaphore(file_cache_semaphore_thread)
|
||||
If m_file_cache(FileName)\Is
|
||||
Debug FileName+" Size:"+Str(m_file_cache(FileName)\Size)+" Timer:"+Str(m_file_cache(FileName)\Timer)+ " new Memory ID:"+Str(m_file_cache(FileName)\Buffer)
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, FileName+" Size:"+Str(m_file_cache(FileName)\Size)+" Timer:"+Str(m_file_cache(FileName)\Timer)+ " new Memory ID:"+Str(m_file_cache(FileName)\Buffer))
|
||||
Else
|
||||
Debug "File not in cache was to full:"+FileName+ " MaxSize:"+Str(configuration\cache\maxsize)+" Actual Size:"+Str(configuration\cache\current/1024/1024)
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "File not in cache was to full:"+FileName+ " MaxSize:"+Str(configuration\cache\maxsize)+" Actual Size:"+Str(configuration\cache\current/1024/1024))
|
||||
EndIf
|
||||
|
||||
UnlockMutex(file_cache_mutex)
|
||||
|
@ -92,7 +92,10 @@ Procedure.s GetFileFromCache(FileName.s, MemoryID.i)
|
|||
String.s = #error_string
|
||||
EndIf
|
||||
UnlockMutex(file_cache_mutex)
|
||||
Debug "Get from cache: "+FileName+">"+String+"-------------------------------------------------------------<"
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "File from Cache:"+FileName)
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "Content: --------------------------------------------------------")
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, String)
|
||||
lhs_log_ext::Out(configuration\log\CachelogUUID, "End Content. ----------------------------------------------------")
|
||||
ProcedureReturn String.s
|
||||
Else
|
||||
ProcedureReturn #error_string
|
||||
|
|
4
lweb.pbi
4
lweb.pbi
|
@ -54,6 +54,8 @@ Module lhs_web
|
|||
AccesslogUUID.s
|
||||
Errorlog.s
|
||||
ErrorlogUUID.s
|
||||
Cachelog.s
|
||||
CachelogUUID.s
|
||||
EndStructure
|
||||
|
||||
Structure server
|
||||
|
@ -254,6 +256,8 @@ Module lhs_web
|
|||
configuration\log\AccesslogUUID = setting
|
||||
Case #conf_Error_logUUID
|
||||
configuration\log\ErrorlogUUID = setting
|
||||
Case #conf_Cache_logUUID
|
||||
configuration\log\CachelogUUID = setting
|
||||
Case #conf_debug_logfile
|
||||
configuration\log\Debuglog = setting
|
||||
Case #conf_debug_disable
|
||||
|
|
20
lweb.pbp
20
lweb.pbp
|
@ -8,7 +8,7 @@
|
|||
<section name="data">
|
||||
<explorer view="../../../bin/purebasic/examples/" pattern="0"/>
|
||||
<log show="1"/>
|
||||
<lastopen date="2021-05-24 22:01" user="renlin" host="linux-3z3y"/>
|
||||
<lastopen date="2021-06-06 09:09" user="renlin" host="renlin-home"/>
|
||||
</section>
|
||||
<section name="files">
|
||||
<file name="inc/lweb_file_cache.pbi">
|
||||
|
@ -44,36 +44,36 @@
|
|||
<fingerprint md5="636558037ff2cab03552fb129e2a4f52"/>
|
||||
</file>
|
||||
<file name="lhs_lib/SYS/lhs_log.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+--"/>
|
||||
<fingerprint md5="6b31d19e01b0030f0864597f48e078de"/>
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="0" panelstate="+--"/>
|
||||
<fingerprint md5="32e22e56e8803aa600edbd64278972a7"/>
|
||||
</file>
|
||||
<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="0" panelstate="+--"/>
|
||||
<fingerprint md5="e71a63777923aebca7171593016d9b8f"/>
|
||||
</file>
|
||||
<file name="lhttpd.pb">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||
<fingerprint md5="ebf734d9cd3289f62402f2e53926a082"/>
|
||||
<fingerprint md5="9ee5a364c639ebe00fd6a85879ce24fd"/>
|
||||
</file>
|
||||
<file name="lsocket.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||
<fingerprint md5="be7d2d564a84dfe303c8e59c7ec78878"/>
|
||||
<fingerprint md5="3c0102c6a6921f13ef7d98f3cace5968"/>
|
||||
</file>
|
||||
<file name="ltls.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||
<fingerprint md5="03aa93c8873d761cfdc9763b38196677"/>
|
||||
<fingerprint md5="d29c2b09c5e10cb9f6b8e362a0d32455"/>
|
||||
</file>
|
||||
<file name="lweb.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||
<fingerprint md5="4d4c182994443de2dffc808a941bbfa3"/>
|
||||
<fingerprint md5="817e2012204d23ee4279b6d487199ef7"/>
|
||||
</file>
|
||||
<file name="lweb_header.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||
<fingerprint md5="33f134da4f3fefc97231572147d3be64"/>
|
||||
<fingerprint md5="38ba04b2f95c396598e3f829256f77f1"/>
|
||||
</file>
|
||||
<file name="server_example.pb">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||
<fingerprint md5="5c49bb34e4235b4ca2d10b87ca4777f4"/>
|
||||
<fingerprint md5="41e876adb9fd6b53c35d0e4b8390d8d0"/>
|
||||
</file>
|
||||
</section>
|
||||
<section name="targets">
|
||||
|
|
|
@ -45,6 +45,8 @@ DeclareModule lhs_web
|
|||
#conf_Access_logUUID
|
||||
#conf_Error_logfile
|
||||
#conf_Error_logUUID
|
||||
#conf_Cache_logfile
|
||||
#conf_Cache_logUUID
|
||||
#conf_runfile
|
||||
EndEnumeration
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ XIncludeFile "lweb.pbi"
|
|||
;*
|
||||
|
||||
Define counter, v_lweb_srv_stop
|
||||
Define Accesslog.s, Errorlog.s
|
||||
Define Accesslog.s, Errorlog.s, Cachelog.s
|
||||
|
||||
;*
|
||||
;* Basic Debug Log initialization:
|
||||
|
@ -42,16 +42,19 @@ lhs_log::Init()
|
|||
;*
|
||||
Accesslog = lhs_log_ext::Create("Accesslog")
|
||||
Errorlog = lhs_log_ext::Create("Errorlog")
|
||||
Cachelog = lhs_log_ext::Create("Cachelog")
|
||||
lhs_log::Out("Errorlog UUID:"+Errorlog)
|
||||
lhs_log::Out("Accesslog UUID:"+Accesslog)
|
||||
lhs_log::Out("Cachelog UUID:"+Cachelog)
|
||||
lhs_log_ext::SetLogFile(Accesslog, "http-s_access.log")
|
||||
lhs_log_ext::SetLogFile(Errorlog, "http-s_error.log")
|
||||
lhs_log_ext::SetLogFile(Cachelog, "http-s_cache.log")
|
||||
lhs_log_ext::Init(Accesslog)
|
||||
lhs_log_ext::Init(Errorlog)
|
||||
|
||||
lhs_web::set_config(lhs_web::#conf_log_Accesslog, Accesslog)
|
||||
lhs_web::set_config(lhs_web::#conf_log_Errorlog, ErrorLog)
|
||||
|
||||
lhs_log_ext::Init(Cachelog)
|
||||
lhs_web::set_config(lhs_web::#conf_Access_logUUID, Accesslog)
|
||||
lhs_web::set_config(lhs_web::#conf_Error_logUUID, ErrorLog)
|
||||
lhs_web::set_config(lhs_web::#conf_Cache_logUUID, Cachelog)
|
||||
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_HTTP_binding, "0.0.0.0")
|
||||
|
|
Loading…
Reference in a new issue