Robochameleon log utility.
- It can be used to log information to different log levels. See below.
- Logging in colors may slow down the code execution. For long and slow operations it's possible to log everything in black (faster) or totally disable the logging (even faster).
Log levels
- ERR Errors. Will also break the code execution.
- WRN Warnings. Use it when the behaviour may create problems if gone unoticed.
- DBG Use it only in custom setups to display information for debugging. Don't use it in units or modules in the library.
- NFO Basic logging level used to display the status of normal operations that may be of interest to the user.
- NFO0 Should mostly used to display pedantic information which may be useful for debugging or to new users.
Logging preferences
WARNING Preferences are persistent. Reset them at the beginning of any script, and set the relevant ones manually to avoid mistakes. After changing the preferences run clear all to make them effective.
- setpref('roboLog', 'logToFile', VALUE) [Default: 0]
- 0: Log to standard output
- 1: Log to file
- 2: Log both to standard output and file
- setpref('roboLog', 'logFile', FILENAME)
- setpref('roboLog', 'logLevel', LEVEL) [Default: Maximum]
- 1: Log errors (ERR)
- 2: Log errors and warnings (ERR, WRN)
- 3: Log errors, warnings and custom debug info (ERR, WRN, DBG)
- 4: Log errors, warnings, custom debug info, general info (ERR, WRN, DBG, NFO)
- 5: Log errors, warnings, custom debug info, general info, and trivial info (ERR, WRN, DBG, NFO, NFO0)
- setpref('roboLog', 'logInBlack', LEVEL) [Default: 1]
- 0: Don't use colors in log output (faster)
- 1: Use colors in log output
Example
% Delete any previous log related settings
if ispref('roboLog')
rmpref('roboLog');
end
robolog('Formatted %s %d', 'WRN', 'warning', 2);
% Enable logging to file only
setpref('roboLog', 'logToFile', 1);
% Set log file
setpref('roboLog', 'logFile', 'myfile.txt');
robolog('Info 3 to myfile.txt', 'NFO');
- Author
- Simone Gaiarin
- Version
- 1
Definition in file robolog.m.