Issue: 14.4 (July/August 2016)
Author: Scott Boss
Author Bio: Scott Boss is the founder of Nocturnal Coding Monkeys, Llc, who specialize in writing custom software. Scott has been a developer, system administrator, storage engineer, consultant, and architect to businesses from startup to global 100.
Article Description: No description available.
Article Length (in bytes): 5,770
Starting Page Number: 81
Article Number: 14411
Related Link(s): None
Excerpt of article text...
This issue we will be looking at Logging Module For Xojo (
https://github.com/IntelligentVisibility/LoggingClass). At the time of writing this column, it was commit "1e49e6a" (there is no version numbering on the module). Mike Cotrone of Intelligent Visibility wrote the module to give us an easy way to log information to a named log file. Many of us use
System.DebugLogto write information out, so we can see what is going on inside our applications. Using
System.DebugLogwrites the information out to the
EventVieweron Windows, or
/var/log/messageson Linux. Which isn't bad, but it is hard to go through just the information for your app as those are consolidated and centralized logs.
I personally prefer to have my application use its own log file. This way I can have my clients send me the log file in case of an issue or problem and there is no outside data in it. Plus, it gives me the ability to control the log file in size, age, number of log files, etc.
To start using the Loggigng Module, open the project (
LoggingClassWithdemo.xojo_binary_project) that is part of the repo. Then copy the module
LogModuleto your application. Then you will need to edit the four constants
kSystemLogFileDirto reference the files and directories you want the logging to go to. The
kErrorLogFile*constants are for the
kSystemLogFile*constants are for the
LogModule.mSystemLog(). You can point both the errors and systems logs to the same file if you wish. Looking at some example code, we can see logging data to the log file:
// 1 is the SystemLog level. has to be 1-4, the higher the number // the less likely it will be logged.
...End of Excerpt. Please purchase the magazine to read the full article.