Log manager provides simple and clear logging sysmem convenient to use for microservices.
winston-microlog was developed in order to provide a way to keep logs from different sources (and parts of sources) in the most convenient and clear way. First of all, the project was created for microservices, where logs from different services are collected in one thread. Thus, the largest unit of logging is services. Services can include instances, which can be different functional parts of the service or just different files.
Unit A1 Unit A2 Unit B1 Unit B2 | | | | | | | | | | | | +--v--------v--+ +--v--------v--+ | | | | | Service A | | Service B | | | | | +------+-------+ +------+-------+ | | | | | | +---> Logfile <---+
To start logging you need to initialize logger for every service and then for every instance.
Example for one service:
const LogManager = "default";const logManager = 'Service';exports"default" = logManager;
const logManager = 'default';const logger = logManager;logger;let db = 'data': 'data';logger;exports'default' = db;
const logManager = 'default';const db = 'default';const logger = logManager;logger;logger;logger;
@SERVICE #DB-CON [10:52] ℹ| Connecting to database... @SERVICE #DB-CON [10:52] ℹ| Database succesfully connected! @SERVICE #MAIN [10:52] ℹ| Service started @SERVICE #MAIN [10:52] ⛔| Test error @SERVICE #MAIN [10:52] ⚠️| Test warning
Note that if you want to pass logger in another module (function, class etc.) execution context wheel be changed and you need to pass logger with their context:
Using with container manager (like docker-compose)
Recomendet way to use winston-logger with managers like docker-compose is hide service name (because it already provided) with showService
const logManager = 'Service' undefined showService: false ;