Article Preview
Buy Now
COLUMN
Column
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 useSystem.DebugLog
to write information out, so we can see what is going on inside our applications. UsingSystem.DebugLog
writes the information out to theconsole.app
on Mac,EventViewer
on Windows, or/var/log/messages
on 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 moduleLogModule
to your application. Then you will need to edit the four constantskErrorLogFile
,kErrorLogFileDir
,kSystemLogFile
, andkSystemLogFileDir
to reference the files and directories you want the logging to go to. ThekErrorLogFile*
constants are for theLogModule.mErrorLog()
and thekSystemLogFile*
constants are for theLogModule.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.