Logging is integrated into Solstice from the ground up. From any model, view or controller, you can call the following method to get access to the central logging services:
Perl
my $logger = $self->getLogService();To log messages:
Perl
$logger->log({
model => $model,
model_id => $model->getID(),
log_file => $filename,
content => $log_message
});The only field that is required is content.
If the log_file isn't specified, log messages will be added to a file called 'log'. All logs are stored in a per application directory inside of the directory specified in your solstice config's data_root.
The log service already knows which user is logged in, as well as the time, so there's no need to include those in the log content.
Here are some example log entries:
Where the content and model_id were specified:
pmichaud May 31 14:39:14 2006 (501) Copied magazine on page 0, in position 1
Where only the content is specified:
pmichaud May 2 14:54:07 2006 Copy of My first non-uw group(2) Subgroups updated
As of .92:
If you need to have a log file without a username or timestamp (for Anonymous logging), you can use the log_anonymous() method, which takes the same arguments as log().