| Supervisor documentation | Contained in the Supervisor distribution. |
Supervisor::Log - A simple logger for the Supervisor environment
$log = Supervisor::Log->new(
info => 1,
warn => 1,
error => 1,
fatal => 1,
debug => 0,
system => $self->config('Name'),
filename => $self->config('Logfile'),
);
$log->info("It's working");
The supervisor captures the stdout and stderr streams from each managed process and redirects them into a log file. The logfile name can be specified.
This module inherits from the Badger::Log::File module. It specifies a logging format and overrides the log() and format() methods to do what I want them to do.
Badger::Log Badger::Log::File Supervisor Supervisor::Base Supervisor::Class Supervisor::Constants Supervisor::Controller Supervisor::Log Supervisor::Process Supervisor::ProcessFactory Supervisor::Session Supervisor::Utils Supervisor::RPC::Server Supervisor::RPC::Client
Kevin L. Esteb, <kesteb@wsipc.org>
Copyright (C) 2009 by WSIPC
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
| Supervisor documentation | Contained in the Supervisor distribution. |
package Supervisor::Log; use 5.008; use DateTime; use base Badger::Log::File; our $FORMAT = "[<time>][<system>] <level>: <message>"; # ---------------------------------------------------------------------- # Public Methods # ---------------------------------------------------------------------- sub log { my ($self, $level, $message) = @_; my $handle = $self->{handle} || $self->acquire; $message = defined($message) ? $message : ""; my $output = sprintf($self->format($level, $message)); $output =~ s/\n+$//; $handle->printflush($output, "\n"); $self->release unless $self->{keep_open}; } sub format { my $self = shift; my $dt = DateTime->now(time_zone => 'local'); my $args = { time => sprintf("%s %s", $dt->ymd('/'), $dt->hms), system => $self->{system}, level => shift, message => shift, }; my $format = $self->{format}; $format =~ s/<(\w+)>/ defined $args->{ $1 } ? $args->{ $1 } : "<$1>" /eg; return $format; } 1; __END__