Hadron logger

Usage no npm install needed!

<script type="module">
  import brainhubeuHadronLogger from 'https://cdn.skypack.dev/@brainhubeu/hadron-logger';


Logger for Hadron


Hadron Logger provides an option to replace the default hadron logger (bunyan) to the one of your choice.


npm install @brainhubeu/hadron-logger --save

More info about installation


Pass the package as an argument for the Hadron bootstrapping function:

// ... importing and initializing other components

hadron(expressApp, [require('@brainhubeu/hadron-logger')], config);

That way, you should be able to get it from the Container like that:

const logger = container.take('logger');
logger.log('Hello, I am your logger');
logger.warm('Look out! I am your logger!');
logger.debug('Am I your logger?');
logger.error('I am not your logger!');

Notice: logger is a container key only for the default logger.


To setup your own logger, you need to provide an adapter first. You can do that by importing the registerAdapter method and calling it with name and provider function for your logger, like that:

const registerAdapter = require('@brainhubeu/hadron-logger').registerAdapter;
registerAdapter('myOwnLogger', function(config) {
  return {
    log: function(message) {
    warn: function(message) {
    debug: function(message) {
    error: function(message) {

Provider takes the Hadron logger config as the first parameter.

After your adapter is set up, you can define your logger in the Hadron configuration and retrieve it using the logger's name.

const hadronConfig = {
  // ...other stuff
  logger: {
    name: 'myLoggerName',
    type: 'myOwnLogger',

// hadron initialization

const logger = Container.take('myLoggerName');

Multiple loggers

You can define multiple loggers for your application. To do that you just need to provide adapters for each of them and define them in the configuration.

const hadronConfig = {
  // ...other stuff
  logger: [
    { name: 'Logger1', type: 'logger1' },
    { name: 'logger2', type: 'logger2' },
    { name: 'logger3', type: 'logger3' },

// hadron initialization