Lumberjack::Dispatcher::EventSource

A Lumberjack dispatcher that dispatches to server sent events for a web application

Lumberjack::Dispatcher::EventSource

A Dispatcher for Lumberjack that emits the log messages as server sent events

image https://github.com/jonathanstowe/Lumberjack-Dispatcher-EventSource/workflows/CI/badge.svg not found

Synopsis

use Lumberjack;
use Lumberjack::Dispatcher::EventSource;
use Cro::HTTP::Router;
use Cro::HTTP::Server;

my $dispatcher = Lumberjack::Dispatcher::EventSource.new

Lumberjack.dispatchers.append: $dispatcher;


my $app = route {
    get -> {
        content 'text/event-stream', $dispatcher.Supply;
    }
};

my Cro::Service $log = Cro::HTTP::Server.new(:host<localhost>, :port<7798>, application => $app);

$log.start;

react whenever signal(SIGINT) { $log.stop; exit; }

There is a slightly more comprehensive example in the examples directory.

Description

This is a Lumberjack::Dispatcher implementation that emits the log messages as JSON (as formatted by Lumberjack::Message::JSON,) on a supply in the format of Server Sent Events. The Supply can be passed as a response to a web toolkit that supports chunked encoding such as Cro or Crust.

This may be useful if you want to expose your logging to the web or to some log archiver or something.

The exact format of the JSON emitted is documented by Lumberjack::Message::JSON

Installation

Assuming you have a working Rakudo installation then you can install this with zef :

zef install Lumberjack::Dispatcher::EventSource

Support

This is a very simple module, really just the composition of some existing things, so it's most likely that if there are bugs they are in EventSource::Server or Lumberjack::Message::JSON However please feel free to report any issues/suggestions/whatever at Github.

Licence and Copyright

This is free software, please see the LICENCE file in the distribution for more details.

Ā© Jonathan Stowe 2021-

Lumberjack::Dispatcher::EventSource v0.0.4

A Lumberjack dispatcher that dispatches to server sent events for a web application

Authors

  • Jonathan Stowe

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Lumberjack::Dispatcher::EventSource

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.