@icon-magic/logger
TypeScript icon, indicating that this package has built-in type declarations

2.3.0-beta.0 • Public • Published

@icon-magic/logger


This package is responsible for exposing all the logging functionality for icon-magic. It contains a wrapper around winston.js for including the filename from where the logs are generated as a label in the logged message.

Logs are written to the following simulataneously:

  1. console - logs of all levels
  2. icon-magic-run.log - logs of all levels
  3. icon-magic-error.log - only error logs

Usage

// Import the logger module and it's interface
import { Logger } from "@icon-magic/logger";

// Instantiate by passing the name of the file. This will be a label in the log message
const LOGGER: logger = new Logger("icon-magic:icon-models:asset");

// Log a debug message
LOGGER.debug("Icon generation has begun");

// Log an error message
LOGGER.error("Oh no! An error has occurred!");

This will print logs of the following format:

<timestamp> [<label>] <logLevel> <msg>

For example,

2019-05-15T17:40:40.056Z [icon-magic:icon-models:asset] debug: Asset test created in /Users/rchitloo/workspace/artdeco-icons-source_trunk/icons/shadows
2019-05-15T17:40:40.060Z [icon-magic:icon-models:asset] debug: Asset creatingError created in /Users/rchitloo/workspace/artdeco-icons-source_trunk/icons/shadows
2019-05-15T17:40:40.060Z [icon-magic:icon-models:icon] error: MissingVariantError: Variant /Users/rchitloo/workspace/artdeco-icons-source_trunk/icons/shadows/creatingError.svg missing for icon /Users/rchitloo/workspace/artdeco-icons-source_trunk/icons/shadows

Methods

The logger object exposes the following methods from winston.logger

  • debug()
  • info()
  • error()

Readme

Keywords

none

Package Sidebar

Install

npm i @icon-magic/logger

Weekly Downloads

4

Version

2.3.0-beta.0

License

BSD-2-Clause

Unpacked Size

12.9 kB

Total Files

11

Last publish

Collaborators

  • thegilby
  • camario25
  • epicmiller
  • rchitloor
  • omayeli