Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 14.4 ('NSTableView')
Instant purchase and download via GumRoad!



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.DebugLog to write information out, so we can see what is going on inside our applications. Using System.DebugLog writes the information out to the console.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 module LogModule to your application. Then you will need to edit the four constants kErrorLogFile, kErrorLogFileDir, kSystemLogFile, and kSystemLogFileDir to reference the files and directories you want the logging to go to. The kErrorLogFile* constants are for the LogModule.mErrorLog() and 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.