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 Init()
|
||||||
Declare Out(ToLog.s, debugger.i = #NoDebug)
|
Declare Out(ToLog.s, debugger.i = #NoDebug)
|
||||||
Declare OutL(LogType.i, ToLog.s, debugger.i = #NoDebug)
|
Declare OutL(LogType.i, ToLog.s, debugger.i = #NoDebug)
|
||||||
|
Declare Disable()
|
||||||
Declare Close()
|
Declare Close()
|
||||||
EndDeclareModule
|
EndDeclareModule
|
||||||
|
|
||||||
Module lhs_log
|
Module lhs_log
|
||||||
Global File_ID.i
|
Global File_ID.i
|
||||||
|
Global log_state.i = #true
|
||||||
|
|
||||||
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
|
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
|
||||||
Global LogFile.s = "/var/log/"+App_Name+".log"
|
Global LogFile.s = "/var/log/"+App_Name+".log"
|
||||||
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
|
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
|
||||||
|
@ -131,6 +134,14 @@ Module lhs_log
|
||||||
LastSize + StringByteLength(String.s)
|
LastSize + StringByteLength(String.s)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure Disable()
|
||||||
|
log_state = #False
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure Enable()
|
||||||
|
log_state = #True
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure LogThread(nix)
|
Procedure LogThread(nix)
|
||||||
Shared Mutex
|
Shared Mutex
|
||||||
Define ToWrite.s
|
Define ToWrite.s
|
||||||
|
@ -183,17 +194,19 @@ Module lhs_log
|
||||||
ProcedureReturn #True
|
ProcedureReturn #True
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure Out(ToLog.s, debugger.i = #NoDebug)
|
Procedure Out(ToLog.s, debugger.i = #NoDebug)
|
||||||
Shared Mutex
|
If log_state
|
||||||
LockMutex(Mutex)
|
Shared Mutex
|
||||||
LastElement(Messages())
|
LockMutex(Mutex)
|
||||||
AddElement(Messages())
|
LastElement(Messages())
|
||||||
Messages() = ToLog
|
AddElement(Messages())
|
||||||
If debugger = #Debug
|
Messages() = ToLog
|
||||||
Debug ToLog
|
If debugger = #Debug
|
||||||
|
Debug ToLog
|
||||||
|
EndIf
|
||||||
|
UnlockMutex(Mutex)
|
||||||
|
SignalSemaphore(Semaphore)
|
||||||
EndIf
|
EndIf
|
||||||
UnlockMutex(Mutex)
|
|
||||||
SignalSemaphore(Semaphore)
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure OutL(LogType.i, ToLog.s, debugger.i = #NoDebug)
|
Procedure OutL(LogType.i, ToLog.s, debugger.i = #NoDebug)
|
||||||
|
|
Loading…
Reference in a new issue