-
Notifications
You must be signed in to change notification settings - Fork 0
Log R4.2 API
Gentilhomme edited this page Mar 2, 2017
·
3 revisions
API for perluim release 4.2 or higher.
Log class is able to reproduce the original nimLog behavior. But my log system it's a lot better if you want a good trace in time (without crossing all logs).
use perluim::logger;
use perluim::main;
my $time = time();
my $Logger;
$Logger = new perluim::logger({
file => "test_probe.log",
level => 5
});
$Logger->log(3,'test_probe started!');
# Do the job here !
# Close the log!
$Logger->finalTime($time);
$Logger->copyTo('output');
R3.0 Is now including Auto-flush.
Level | Header |
---|---|
0 | Critical |
1 | Error |
2 | Warning |
3 | Info |
4 | Debug |
5 | Empty |
6 | Success |
The log constructor take four argument :
- file : The name of the log.
- level : The level of the log.
- size : The maximum size of the log (put 0 if you want no maximum logsize).
- rewrite : Rewrite configuration on startup. (Put no if you want nimLog behavior with log size).
Reconfigure / set loglevel
$Logger->setLevel($CFG->{setup}->{loglevel});
Close logfile.
$Logger->log(3,'Hello world!');
$Logger->log(0,'Critical error!');
Return CA UIM formatted date!
Exemple : Nov 22 09:58:06
Clean directories when the time is outdated.
maxAge is second
$Logger->cleanDirectory('output',4000);
Print the final execution time.
my $ScriptExecutionTime = time();
# Script here
$Logger->finalTime($ScriptExecutionTime);
return something like that Final execution time = 0.00 second(s) [0.00 minutes]!
Copy the logfile to a another destination !
Warning copyTo method close the log file.
my $ExecutionDate = $SDK->getDate();
$SDK->createDirectory("output/$ExecutionDate");
$Logger->copyTo("output/$ExecutionDate");