Help language development. Donate to The Perl Foundation

LogP6-Writer-Journald cpan:ATROXAPER last updated on 2019-04-11

LogP6-Writer-Journald-1.3.2/

Build Status

NAME

LogP6::Writer::Journald - writer implementation for journald - a system service for collecting and storing log data, introduced with systemd.

TABLE OF CONTENTS

SYNOPSIS

LogP6 can be adopted for your any logging need. This module provides possibility to write your logs in journald;

CONFIGURATION

You can configure the writer from code by instantiating object of LogP6::WriterConf::Journald class. It takes the following parameters:

Note that using use-code-file, use-code-line or use-code-func properties will slow your program because it requires several callframe calls on each resultative log call;

Also you can configure the writer in configuration file uses custom type writer and "fqn-class": "LogP6::WriterConf::Journald" as any other configurations in LogP6.

EXAMPLES

You can see example of using LogP6 in its README. Here are examples of journald writer configuration.

In Perl 6:

use LogP6 :configure;

writer(LogP6::WriterConf::Journald.new(
  # name, pattern and auto-exceptions as in standard writer
  :name<to-journald>, :pattern('%msg'), :auto-exeptions
  # which additional information must be written
  :use-priority,
  :use-code-line,
  :use-code-file,
  :use-code-func,
  :use-mdc
  # if you want to use custom systemd connector
  # :systemd(CustomSystemd.new)
));

Or in configuration file:

{"writers": [{
  "type": "custom",
  "require": "LogP6::WriterConf::Journald",
  "fqn-class": "LogP6::WriterConf::Journald",
  "args": {
    "name": "to-journald",
    "pattern": "%msg",
    "auto-exceptions": true,
    "use-priority": true,
    "use-code-file": true,
    "use-code-line": true,
    "use-code-func": true,
    "use-mdc": true
  }
}]}

REQUIREMENTS

By default the writer uses native call to systemd library. If you do not want to provide your own LogP6::Writer::Journald::Systemd implementation then you need to have systemd library on host you run a program. On Ubuntu machine you can install it like:

sudo apt-get install libsystemd-dev

AUTHOR

Mikhail Khorkov atroxaper@cpan.org

Source can be located at: https://github.com/atroxaper/p6-LogP6-Writer-Journald. Comments and Pull Requests are welcome.

COPYRIGHT AND LICENSE

Copyright 2019 Mikhail Khorkov

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.