LIB_LOG

This library is – for me – a must.

It allows to manage a log file, useful for saving information, output and so on. Many of the library I wrote use it as output for debugging info.
The file is a simple text file, so it can be opened and readed with any tools, information are in plain text, just a timestamp and comment (hh:mm:ss : text).
No JSON or anything else used, but of course you can save the ouput message in the way you want, even crypted if you want!

Usage

First of all you need to choose a place and a name for the log file you want to create.

InitLog(fileName$,separated,print_console)

If no fileName is passed it will be created a folder called CFG and a logfile in the format d% b% %Y_log.txt, otherwise it will be created the file with the name choosen.

If SEPARATED is TRUE or 1 the library will create a new file – with a timestamp in the filename – to save different ‘snapshot’, useful to keep track.

The last parameter PRINT_CONSOLE – default is TRUE/1 – determines if the message must be printed both in the console output and in the log file or not.

To write to the logfile just use

LogPrint(message:String,disabled:Int=0)

Message is what will be saved.

Disabled – default 0 – is used (if 1 or TRUE) to disable the registration on the logfile of the message.

A special string *- is used to save a ‘separator’ (like this ——) in the logfile.

It’s possible to pause/restart the use of the Logfile using DisableLog() and EnableLog() functions. If DisableLog() is called, any LogPrint() calls is ignored and not saved.

Last command is StopLog() used to close operations. It’s not needed – the filestream is opened and closed at every LogPrint() calls, just put an ‘end’ to the logfile.

SIDE NOTE

As Lig_log is using filestream any LogPrint() operations could impact in performace time as the application needs to write to the filesystem.
The approach of the Logfile is to have a ‘realtime’ log of what happens: if the app bombs out you can read the last LogPrint() output… so you can have a sort of ‘place’ of where the bug can be.

I was working on a profiler some years ago – the idea is just to ‘save’ informations about variables and objects at determinated time-frame.
I must restart the project, it did seem a good idea at the time!

A second version of this library – called Lib_log2 is present in the Library package. But consider that just an experiment, I never updated it. The main idea was to move everything to an OO approach, adding more ‘controls’ on the type of output (ie: JSON or automatic output for arrays and lists and so on).
At the end I found that the simple approach of Lib_log is what I need and offers what is really necessary.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close