Skip to main content

Introduction

๐Ÿ”ฅwarning

WIP Documentation!

Simple Javascript Logger


GitHub Licensenpm versionnpm minified sizenpm total downloads

โ“ logger#

The logger package is a standalone extension for AgileTs that improves the logging experience, by letting you precisely configure the logging behavior. Without the logger package, AgileTs only logs warn and error logs. These logs cannot be customized or turned off. However, with the logger extension installed, you can completely customize what messages should be logged, how these messages should look like and much more. All you need to do to configure the logging behavior of AgileTs, is to call assignSharedAgileLoggerConfig() and specify your customized logger configuration.

import {assignSharedAgileLoggerConfig, Logger} from '@agile-ts/logger';
assignSharedAgileLoggerConfig({  active: true,  level: Logger.level.DEBUG,  timestamp: true})

โœ๏ธ Standalone#

The AgileTs Logger Class can also be used without AgileTs.

const logger = new Logger();

Some of its capabilities are to:

  • ๐ŸŽญ categorize log messages#

    Log messages in different upper categories to be able to roughly classify log messages.

    logger.log("I'm a log message!");logger.debug("I'm a debug message!");logger.info("I'm a info message!");logger.warn("I'm a warn message!");logger.error("I'm a error message!");logger.success("I'm a success message!");logger.trace("I'm a trace message!");logger.custom('jeff', "I'm a custom jeff message!");
  • ๐ŸŽฒ filter log messages#

    Filter log messages by tag or type in order to see only logs that matter right now.

    // Filter by 'type'logger.setLevel(Logger.level.WARN);logger.debug('Boring Debug Message.'); // Doesn't get loggedlogger.warn('Important Warning!'); // Does get log
    // Filter by 'tags'logger.if.tag(['runtime']).info(`Created Job '${job._key}'`, job);
  • ๐ŸŽจ style log messages (color, font-weight)#

    Style log messages to make it easier to distinguish between different log types and recognise important log messages more quickly. Log Custom Styles Example

  • ๐Ÿ”จ customize log messages (prefix, timestamp)#

    Customize log messages to identify searched logs more swiftly.

    logger.debug('Hello there!'); // Logs: 'Agile: Hello there!'
  • ๐Ÿšซ disable all log messages#

    logger.debug('Exciting Debug Message.'); // Logs: 'Boring Debug Message.'logger.isActive = false;logger.debug('Boring Debug Message.'); // Doesn't get loggedlogger.warn('Important Warning!'); // Doesn't get logged

๐Ÿš€ Quick Links#