PDA

View Full Version : Log007 - lightweight logger with license to kill



Petr Schreiber
26-03-2016, 14:13
This custom logging solution allows you to log messages as usual, but some logging severities have special behaviour, allowing to trigger execution stop or check for error.
I started developing it as part of solution for my m15Model project, but it is independent and can be used in any application.

Log007 is provided with full source code and unit tests here:
https://github.com/petrSchreiber/Log007

(https://github.com/petrSchreiber/Log007)The official documentation and example of use is available at Wiki (https://github.com/petrSchreiber/Log007/wiki).
The latest release is available for download (https://github.com/petrSchreiber/Log007/releases).

Just to give idea:


Uses "file"

#INCLUDE "log007.tbasicu"

Global agent As Log007("log.txt")

Function TBMain()

agent.Note("debug", Function_Name, "Program started")
String buffer = LoadData("C:\Not\Really\Existing.txt")

If agent.InTrouble Then
MsgBox 0, agent.LastTrouble
Else
MsgBox 0, buffer
End If

End Function

Function LoadData(fileName As String) As String

If FILE_Exists() Then
Return FILE_Load(fileName)
Else
agent.Note("error", Function_Name, "Could not locate " + fileName)
End If

End Function


Produces this log file:


03-26-2016 19:43:49 (DEBUG) [TBMAIN] Program started
03-26-2016 19:43:49 (ERROR) [LOADDATA] Could not locate C:\Not\Really\Existing.txt



Petr

Petr Schreiber
27-03-2016, 19:39
Updated with new release, to fix gitHub line endings to CRLF. Thanks Primo!


Petr

Petr Schreiber
29-03-2016, 19:01
Update with new release, to allow control over file writes.


Petr