lhs_log Enable / Disable Logger output.
This commit is contained in:
parent
7ab2255ff0
commit
b11846a3af
1 changed files with 23 additions and 10 deletions
|
@ -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
|
||||
|
@ -183,17 +194,19 @@ Module lhs_log
|
|||
ProcedureReturn #True
|
||||
EndProcedure
|
||||
|
||||
Procedure Out(ToLog.s, debugger.i = #NoDebug)
|
||||
Shared Mutex
|
||||
LockMutex(Mutex)
|
||||
LastElement(Messages())
|
||||
AddElement(Messages())
|
||||
Messages() = ToLog
|
||||
If debugger = #Debug
|
||||
Debug ToLog
|
||||
Procedure Out(ToLog.s, debugger.i = #NoDebug)
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue