Logging framework

WARNING

Logging framework is only available within Lua VM

Log display

How to use log framework to print a log trace:

local log = require"log"

log(module, severity, fmt, ...)

fmt parameter (and next ones) is to be used to format text like in print function.

Example
log("GENERAL", "INFO", "Starting %s", "some module")

produces following output:

2011-01-26 11:31:59 GENERAL-INFO: Starting some module
Format configuration

Those parameters can be modified using Agent Config (see Config section), or directly by modifying module values:

Fallback printing

Log module can fail to format log because of :

When such an error is detected, the log uses fallback printing and produces something like:

Error in the log formating! (bad argument #2 to '?' (string expected, got no value)) - Fallback to raw printing:
module=(something), severity=(INFO), format=("%s"), args=()

INFO

Fallback printing output is stored like any other log when using log storing policies

Log filtering

Before being printed or stored, log are filtered depending on the severity (i.e. ordered levels) chosen for the log.
The filtering is done by module:

Log level per module can be configured either by using Agent config, or using log.setlevel function

Here is the order of the levels configuration, from the most restrictive to the most verbose level:
'NONE', 'ERROR', 'WARNING', 'INFO', 'DETAIL', 'DEBUG', 'ALL'

Filtering examples:
if "TEST" module minimum level is set to "WARNING", then a call to log("TEST", "INFO", "something") will not be discarded.

If the log severity is not in previous level list, the log is not filtered.

INFO

Log filtering applies for both printing and storing logs, i.e. if a log is filtered/discarded, log storing policies don't apply for this log

Log colors

Only, ERROR, WARNING, DEBUG, INFO, DETAIL have custom colors that can be changed for now.
Log colors are added in Agent, standalone log module doesn't produce color.
To be activated, config.log.enablecolors has to be set.

Once activated, the terminal emulator has to support the ASCII control characters used to produce the colors.

INFO

Log colors are not stored when using log storing policies

Log policies

A log policy is to determine how/when to store logs in flash/persistent storage, eventually using a RAM buffer to store them temporarily.

Main features / Overview

Existing Policies:
Note: Each policy needs to have parameters to be initialized.

INFO

For now, those limitations apply to log policies:

More details about implementation and low level API can be found in Log storing internal API and implemetation details

Log upload M3DA Command

Note: feature for Agent only

In order to identify the uploaded logs, the file is uploaded with this name

INFO

Agent_deviceid_type_ts.log

where some fields are dynamic:

For LogUpload command description, please see : Device Management page.

FTP upload security

For FTP upload, the Agent can used user/pwd parameters to upload to a FTP server which requires to login.
Those parameters are to be set in Agent Configuration. Please refer to Agent Configuration log subsection to correctly set FTP user and password parameters.