3.0.4 • Published 3 years ago

loggerhythm v3.0.4

Weekly downloads
891
License
MIT
Repository
github
Last release
3 years ago

Loggerhythm

A winston-wrapper to log in a debug-like manner including namespaces

Usage

Loggerhythm exports a Logger-class, whose instances have different log-functions for different log-levels. the avaliable loglevels are:

  1. error
  2. warn
  3. info
  4. verbose

error logs to stderr, everything else logs to stdout!

Example

const Logger = require('loggerhythm').Logger;
// import {Logger} from 'loggerhythm'; // for TypeScript

const logger = new Logger('readme-namespace');
// alias: logger = logger.createLogger('readme-namespace');

logger.info('foo');

The output would look like this (the different log-leves use different colors):

2016-08-30T14:06:33.751Z - info:     [readme-namespace] foo
2016-08-30T14:06:33.752Z - warn:     [readme-namespace] bar

Methods

Static

The Logger-Class has static methods, that can be used to globally set loggerhythm-config and register global log-hooks:

const Logger = require('loggerhythm').Logger;
// import {Logger, LogLevel} from 'loggerhythm'; // for TypeScript

// get informed about all Logs everywhere
const subscription = Logger.subscribe((logLevel, namespace, message, ...logObjects) => {
  // do stuff
});

// do stuff

// unsubscribe
subscription.dispose();

Instance-methods

The Instances of the Logger-class have a log-method for every loglevel and a subscribe-method to get informed about logs of that instance

const Logger = require('loggerhythm').Logger;
// import {Logger} from 'loggerhythm'; // for TypeScript

const logger = Logger.createLogger('readme-namespace');

// get informed about all the logs of that instance
const subscription = Logger.subscribe((logLevel, namespace, message, ...logObjects) => {
  // namespace will always be 'readme-namespace' here
  // do stuff
});

logger.error('error-log', new Error('hello'));
logger.warn('warning-log');
logger.info('have some info', {v1: 1, v2: 2, test: ['some', 'test', 'array']});
logger.verbose('some', 'more detailed', 'info');

// this loggers namespace will be 'readme-namespace:child-logger-lamespace'
const logger2 = logger.createChildLogger('child-logger-lamespace');

// do stuff

// unsubscribe
subscription.dispose();
@process-engine/process_engine_runtime@process-engine/process_engine_core@atlas-engine/core_domain.process_model_execution@infinitebrahmanuniverse/nolb-logg@everything-registry/sub-chunk-2098@atlas-engine/core_domain.endpoint.http@atlas-engine/api.endpoint.http@atlas-engine/api.server@atlas-engine/api.services@atlas-engine/core_domain.application.minimal@atlas-engine/core_domain.application.standalone@atlas-engine/core_domain.client.http@atlas-engine/admin_domain.application.minimal@atlas-engine/admin_domain.client.http@atlas-engine/atlas_engine_admin_client@atlas-engine/core.endpoint.http@atlas-engine/core.process_model_execution@atlas-engine/core.process_model_parser@atlas-engine/database.adapter.sequelize@atlas-engine/process_engine_proxy@atlas-engine/runtime_domain@atlas-engine/runtime_domain.client.http@atlas-engine/sequelize_connection_manager@atlas-engine/user_domain.application.minimal@atlas-engine/user_domain.application.standalone@atlas-engine/user_domain.endpoint.http@essential-projects/http_socket_adapter_socketio@essential-projects/http_socket_adapter_websocket@essential-projects/scheduler_extension@process-engine/process_model.service@process-engine/skeleton@process-engine/skeleton-electron@process-engine/timers.repository.sequelize@process-engine/token_history_api_http@process-engine/kpi_api_http@process-engine/logging_api_http@process-engine/correlation.service@process-engine/correlations.repository.sequelize@process-engine/cronjob_history.repository.sequelize@process-engine/consumer_api@process-engine/metrics_api_http@process-engine/process_engine_client@process-engine/external_task_api_core@process-engine/external_task_api_http@process-engine/external_task_sample_workeremail_repository@process-engine/process_model.repository.sequelize@process-engine/consumer_api_client@process-engine/consumer_api_core@process-engine/consumer_api_http@process-engine/external_task_api_client@process-engine/flow_node_instance.repository.sequelize@process-engine/iam@process-engine/management_api_client@process-engine/management_api_core@process-engine/persistence_api.repositories.sequelize@process-engine/persistence_api.services@process-engine/process_engine@essential-projects/auth@essential-projects/http_socket_adapter@essential-projects/metadata@essential-projects/sequelize_connection_manager@essential-projects/timing@essential-projects/event_aggregator@essential-projects/http_contracts@essential-projects/http_extension@atlas-engine/admin_domain.application.standalone@atlas-engine/admin_domain.endpoint.http@atlas-engine/admin_domain.services@atlas-engine/event_aggregator@atlas-engine/http_contracts@atlas-engine/http_extension@atlas-engine/iam@atlas-engine/persistence.repositories.sequelize@atlas-engine/process_model@atlas-engine/process_model_parser@atlas-engine/timing@atlas-engine/user_domain.client.http@atlas-engine/user_domain.services@atlas-engine/persistence.endpoint.http
3.0.5-feature-1

3 years ago

3.0.4-feature-1

3 years ago

3.0.4

5 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago