lhs_log Enable / Disable Logger output.

This commit is contained in:
René Linder 2021-05-26 09:56:46 +02:00
parent 7ab2255ff0
commit b11846a3af

View file

@ -48,11 +48,14 @@ DeclareModule lhs_log
Declare Init()
Declare Out(ToLog.s, debugger.i = #NoDebug)
Declare OutL(LogType.i, ToLog.s, debugger.i = #NoDebug)
Declare Disable()
Declare Close()
EndDeclareModule
Module lhs_log
Global File_ID.i
Global log_state.i = #true
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
Global LogFile.s = "/var/log/"+App_Name+".log"
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
@ -131,6 +134,14 @@ Module lhs_log
LastSize + StringByteLength(String.s)
EndProcedure
Procedure Disable()
log_state = #False
EndProcedure
Procedure Enable()
log_state = #True
EndProcedure
Procedure LogThread(nix)
Shared Mutex
Define ToWrite.s
@ -184,16 +195,18 @@ Module lhs_log
EndProcedure
Procedure Out(ToLog.s, debugger.i = #NoDebug)
Shared Mutex
LockMutex(Mutex)
LastElement(Messages())
AddElement(Messages())
Messages() = ToLog
If debugger = #Debug
Debug ToLog
If log_state
Shared Mutex
LockMutex(Mutex)
LastElement(Messages())
AddElement(Messages())
Messages() = ToLog
If debugger = #Debug
Debug ToLog
EndIf
UnlockMutex(Mutex)
SignalSemaphore(Semaphore)
EndIf
UnlockMutex(Mutex)
SignalSemaphore(Semaphore)
EndProcedure
Procedure OutL(LogType.i, ToLog.s, debugger.i = #NoDebug)