Skip to content

ArthurianX/pino-h3-elastic-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pino-h3-elastic-logger

An ElastichSearch logging flow built from a small client library that talks with an H3 lightweight server which runs pino and the pino-elasticsearch transport

Logger.PoC.mp4

Considerents

  • This is an intermediate solution to a logging problem we're facing.
  • The service can be scaled in as many instances as needed.
  • When it will become a bottleneck, we can move the backpressure from the application to a broker like pino-mq or pino-kafka
  • The purpose of it is for the client and the API to remain in a familiar state, and then we can change the logging transport to whatever we want.

See it in action

See the console logger in action live on StackBklitz (Open the page and then the console)

Usage

  • Install client using npm install pino-logger-client --save from npm
  • Import with import { Logger } from 'pino-logger-client'
  • Instantiate and configure the logger class with const logger = new Logger(API_URL, LoggerName);, LoggerName is the name that will appear in the logs, it's also optional.
  • Use its methods logger.info|warn|error|success('message')
  • The logger also registers some global error listeners, which can be unregisterd with logger.unregisterListeners()
  • Preferably run the backend somewhere in your infrastructure and configure the logger with the URL

Local development console helper

When process.env is not production then any log will appear in the browser console like this:

image

The colored styling is also supported in terminal consoles when running in a Webpack or other compiled project, as long as the terminal supports colors.

How to Develop & Run all the services locally

The pre-requirements to this are a properly set up Node and Docker environment

  • cd api && npm run dev-stack will start H3 API server and instances of ElasticSearch and Kibana
  • in a different terminal cd client && npm run example-prod will build the client with microbundle and serve the example index.html file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published