File: Logger.pm

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (63 lines) | stat: -rw-r--r-- 925 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Munin::Node::Logger;

use warnings;
use strict;


BEGIN {
    use Exporter();
    our @ISA    = qw(Exporter);
    our @EXPORT = qw(&logger);
}


sub logger {
    my $text  = shift;
    my @date  = localtime (time);

    chomp ($text);
    $text =~ s/\n/\\n/g;

    printf STDERR ("%d/%02d/%02d-%02d:%02d:%02d [%d] %s\n",
                   $date[5]+1900,
                   $date[4]+1,
                   $date[3],
                   $date[2],
                   $date[1],
                   $date[0],
                   $$,
                   $text,
               );

    return;
}


1;


__END__

=head1 NAME

Munin::Node::Logger - The logger for munin node.

=head1 SYNOPSIS

Exports a logger() subroutine.

 use Munin::Node::Logger;

 logger("Nice log message");

=head1 SUBROUTINES

=over

=item B<< logger() >>

  logger($message);

Writes $message to STDERR together with the timestamp and process id.

=back