Sergey Poznyakoff

NAME

Mojo::Log::Syslog - syslog for Mojo projects

SYNOPSIS

    use Mojo::Log::Syslog;

    $logger = new Mojo::Log::Syslog(facility => 'user',
                                    ident => 'myapp',
                                    level => 'warn');

    app->log($logger);

DESCRIPTION

Syslog-based logger for Mojo applications.

CONSTRUCTOR

The Mojo::Log::Syslog constructor takes the following keyword arguments, all of which are optional:

facility => FACILITY

Sets the syslog facility to use. Valid facility names are: auth, authpriv, cron, daemon, ftp, kern, local0 through local7, lpr, mail, news, user, and uucp. See also Sys::Syslog(3), section Facilities.

The default is user.

ident => STRING

Syslog message identifier. Defaults to the base name from $0.

logopt => OPTLIST

Defines the list of options for openlog. OPTLIST is either a string with comma-separated option names or a list reference containing option names. The following two options are equivalent:

    logopt => "ndelay,pid,nowait"

    logopt => [qw(ndeay pid nowait)]

See Sys::Syslog(3) for a list of available option names.

Defaults to ndelay,pid.

level > NAME

Sets minimum logging level. See Mojo::Log, for a list of levels.

METHODS

All methods are inherited from Mojo::Log. The methods debug, warn, info, and error log their messages using the corresponding syslog priorities. The method fatal uses the crit (LOG_CRIT) priority.

EXAMPLE

Using with Mojolicious::Lite

    use Mojolicious::Lite;
    use Mojo::Log::Syslog;

    my $logger = new Mojo::Log::Syslog(facility => 'local0',
                                       level => 'warn');
    app->log($logger);

Using with Mojolicious

    package MyApp;
    use Mojo::Base 'Mojolicious';

    sub startup {
        my $self = shift;
 
        my $logger = new Mojo::Log::Syslog(facility => 'local0',
                                           level => 'warn');
        $self->app->log($logger);
    }

SEE ALSO

Mojo::Log(3), Mojolicious(3), Mojolicious::Guides(1), http://mojolicious.org.