Giter Site home page Giter Site logo

lumberjack-dispatcher-eventsource's Introduction

Lumberjack::Dispatcher::EventSource

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

Build Status

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's People

Contributors

jonathanstowe avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.