Nodeschool Public Materials
Miss any of our Open RFC calls?Watch the recordings here! »

logary

5.1.0-beta.0 • Public • Published

Logary JS

This is the JavaScript logger for capturing errors in web browsers and reporting them to Logary.

Logary is a free and open source logging framework. It's also a fully functional JavaScript logging framework which is extremely open to extension, because it's all composed from pure functions.

Installation

With NPM

npm install logary --save

with Yarn

yarn add logary

How to use

import Logary, { build, /* send */ getLogger, defaultTarget, Message } from 'logary'
// Supply this for your own user
const user = { id: 'abc', name: 'A B', email: 'a.b@example.com' } 
 
// Where to send logs?
const target = defaultTarget; // OR:
 
// ALTERNATIVELY: You can have one of these globally per application.
// const filter = next => req => next(req); // No infrastructure/non-functional requirements on requests
 
// A CUSTOM TARGET (uncomment send, filter, above):
// const target = Targets.logaryService({
//   path: 'http://localhost:10001/i/logary',
//   send: send(), // OR:
//   send: filter(send())
// })
 
// This instance is configured for the example user:
// You can have one of these prepared when the user logs in, in the user state store.
const logary = Logary(user, target, "MyWebApp");
 
// With 'build' we get a "live" function that can send to a target/server, use it to log
// You can have one of these in each of your module "screens"/parents
const sendMessage = build(logary, getLogger(logary, "MyModule"))
 
// Send a message!
// You can have one of these whereever you need to track stuff!
sendMessage(Message.event("App started")).subscribe()

You can spawn Rutta server-side as a docker container, to ingest logs:

$ docker run -p 10001:10001 --rm -it haaf/rutta router --listener http 0.0.0.0:10001 json --target console://./
 

logary-js-rutta

You can choose between the different targets when forwarding the logs (see the main logary repo)

For details about the object model that you use to log, see https://github.com/logary/logary/blob/master/README.md#tutorial-and-things-around-message

Install

npm i logary

DownloadsWeekly Downloads

126

Version

5.1.0-beta.0

License

MIT

Unpacked Size

76.5 kB

Total Files

92

Homepage

logary.tech/

Last publish

Collaborators

  • avatar