Flyt Logger
A small logging library for use within flyt node integrations. Flyt Logger is a thin wraper around the
winston and can send logs over UDP or Console.
Usage
Install
yarn add @flytio/flyt-logger
Import FlytLogger. Create an instance of a logger using constructor. Preferably at the begining of a request.
import { FlytLogger } from '@flytio/flyt-logger';
const logger = new FlytLogger();
Optionally you can pass requestId as a first parameter, and transport options as a second one. You can use helper factory functions to do this. You can read more about options here
import {
createTransport,
FlytLogger,
TransportType
} from '@flytio/flyt-logger';
const logger = new FlytLogger('fsdh-4234-23jh', {
transports: [
createTransport(TransportType.File, fileOptions),
createTransport(TransportType.UDP, udpOptions),
createTransport(TransportType.Console, consoleOptions)
]
});
Once we have initialised we can use any of the logging methods available. Each logging method accepts a message and an optional metadata object if you wish to send any other data that you think appropiate.
logger.info('sendCollectionOrder request started');
logger.debug(`pos response: ${JSON.stringify(responseFromPos)}`);
logger.error(`order failed to send: ${JSON.stringify(error)}`);