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
|
||||||
|
@ -184,6 +195,7 @@ Module lhs_log
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure Out(ToLog.s, debugger.i = #NoDebug)
|
Procedure Out(ToLog.s, debugger.i = #NoDebug)
|
||||||
|
If log_state
|
||||||
Shared Mutex
|
Shared Mutex
|
||||||
LockMutex(Mutex)
|
LockMutex(Mutex)
|
||||||
LastElement(Messages())
|
LastElement(Messages())
|
||||||
|
@ -194,6 +206,7 @@ Module lhs_log
|
||||||
EndIf
|
EndIf
|
||||||
UnlockMutex(Mutex)
|
UnlockMutex(Mutex)
|
||||||
SignalSemaphore(Semaphore)
|
SignalSemaphore(Semaphore)
|
||||||
|
EndIf
|
||||||
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