source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/LoggerBackend/File.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 569 bytes
Line 
1package Ocsinventory::LoggerBackend::File;
2use strict;
3
4sub new {
5  my (undef, $params) = @_;
6
7  my $self = {};
8  $self->{config} = $params->{config};
9  $self->{logfile} = $self->{config}->{logdir}."/".$self->{config}->{logfile};
10
11
12  bless $self;
13}
14
15sub addMsg {
16
17  my ($self, $args) = @_;
18
19  my $level = $args->{level};
20  my $message = $args->{message};
21
22  return if $message =~ /^$/;
23
24  open FILE, ">>".$self->{config}->{logfile} or warn "Can't open ".
25  "`".$self->{config}->{logfile}."'\n";
26  print FILE "[".localtime()."][$level] $message\n";
27  close FILE;
28
29}
30
311;
Note: See TracBrowser for help on using the repository browser.