Log
- Class to handle AURORA REST-server logging through a Content::Log-class in an a easy way.
use Log;
# instantiate
my $db="/path/to/db/file.db";
my $log=Log->new(location=>"DBI::SQLite::dbname=$db",name=>"log",user=>"",pw=>"");
# send log entry
if (!$log->send(entity=>123,loglevel=>$Content::Log::LEVEL_FATAL,logmess=>"This went sideways!",logtag=>"SOMETAG")) {
print "Failure: ".$log->error();
} else {
print "Success!";
}
# load log entries
my $coll=$log->receive();
Class to handle AURORA REST-server logging through a Content::Log-class in a easy and quick way.
Class constructor.
Required parameters are location (dbi data_source), name (database table name to save to), user (username to connect as), pw (password to connect with). Optional parameter is pwfile (file to read pw to connect with from), but this requires the pw parameter to not be specified or blank.
Returns the class instance.
Sends a log entry.
Possible parameters are (in the shape of key=>value pairs): logtime (hires time of log event), entity (id of entity from database), loglevel (loglevel from Content::Log), logtag (tag for message, optional) and logmess (log message to be sent).
Required parameters are none, but it is advised to answer at least entity and logmess. Time is automatically taken from current time if not answered and loglevel defaults to Content::Log::LEVEL_INFO.
Upon successful send returns 1 and upon failure 0.
Error message of a failure can be read by calling the error()-method.
Receives data from DataContainer into Content::Log-instances in a ContentCollection.
No input required.
Returns ContentCollection instance upon success, undef upon failure.
Deletes all the content of the ContentCollection specified.
Input is the ContentCollection instance that are to be deleted from the database.
The deletion process is transactional, so either all entries in the ContentCollection is deleted or none. It will perform a rollback on any failure.
Returns 1 upon success, 0 upon failure. Please check the error()-method for more information upon failure.
See DataContainer-class for an explanation of this method.
The name attribute here means table-name.
See DataContainer-class for an explanation of this method.
The location attribute here means DBI data_source.
Returns or sets the user name wherewith to connect to the database.
Returns or sets the password wherewith to connect to the database.
Returns or sets the password file to read the password from when connecting to the database.
Returns the last known error message of this class.
No input required and return a scalar with the message or a blank (if none).