Skip to content

Simple JavaScript logger written in TypeScript that can be used in browser or node application.

License

Notifications You must be signed in to change notification settings

SimplrJS/simplr-logger

Repository files navigation

Simplr Logger

Simple JavaScript logger written in TypeScript.

The package is most useful when used with TypeScript.

Get started

npm install simplr-logger

Building logger

With default configuration

import { LoggerBuilder } from "simplr-logger";

const logger = new LoggerBuilder();

With configuration builder

import { LoggerBuilder, LoggerConfigurationBuilder, LogLevel } from "simplr-logger";

const config = new LoggerConfigurationBuilder()
    .SetLogLevel(LogLevel.Trace)
    .Build();

const logger = new LoggerBuilder(config);

With simple object

import { LoggerBuilder, LoggerConfigurationBuilder, LogLevel, Handlers } from "simplr-logger";

const logger = new LoggerBuilder({
    LogLevel: LogLevel.Trace,
    WriteMessageHandler: new Handlers.ConsoleMessageHandler()
});

Using logger

Logging with methods

logger.Critical("Critical", "message");
logger.Debug("Debug", "message");
logger.Error("Error", "message");
logger.Info("Info", "message");
logger.Warn("Warn", "message");

Logging with log level

logger.Log(LogLevel.Information, "Info message");
logger.Log(LogLevel.Critical, new Error("Critical error"));

API

TODO

License

Released under the MIT license.