Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@fliegwerk/logsemts

fliegwerk309MIT0.4.3TypeScript support: included

A semantic logging solution implemented with TypeScript

logger, logging, typescript, semantic, color, color-coded, browser, nodejs

readme

LogSemTS Logo

@fliegwerk/logsemts - A modular, semantic logger written in TypeScript

npm package | Library Documentation

CI ShiftLeft Scan CodeQL Coverage Status Maintainability Rate on Openbase

A modular, color-coded, TypeScript-based semantic logger that can be used in NodeJS, the browser and in many other scenarios.

Example

// Import the logger:
import Logger, { BrowserLogger } from '@fliegwerk/logsemts';

// Create a new logger
const logger = new Logger({
    loggers: [BrowserLogger()] // that exclusively outputs to the browser dev tools
});

// get a new subsystem logger for the API Client
const apiClientLogger = logger.getComponentLogger('API Client');

// log a success message
apiClientLogger.success('Data fetched successfully');

Installation

`shell script $ npm install @fliegwerk/logsemts


or

```shell script
$ yarn add @fliegwerk/logsemts

Concept

Concept Overview Diagram

There are three primary components in logsemts:

  • Component Loggers: Logger objects for specific subsystems (for example, an API connector and a login form). These objects contain functions like .log(), .debug(), .warn(), etc. to log messages regarding this subsystem.
  • Log Functions: Functions that log a message to a specific target. Targets could be the Browser's Developer tools, a Database and an API.
  • Core: The library's core consists of the Logger class. Usually, only one instance of that class gets used in an application. It manages the different components (Component Loggers get created using the logger.getComponentLogger(name) function) and Log Functions. It also forwards the messages from the Component Loggers to the registered Log Functions.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.4.3 (2022-01-28)

Bug Fixes

  • Fix security vulnerabilities in dependencies (e438f27)

0.4.2 (2021-05-09)

Bug Fixes

  • serializer: Use toISOString for JSON Date representation (0b03deb)

0.4.1 (2021-05-09)

Features

  • serializer: Add support for Date objects (d5b8344)

0.4.0 - 2020-09-15

Changed

  • improved README.md

    Security

  • Updated cross-fetch to resolve vulnerability in its dependency node-fetch

    0.4.0-0 - 2020-09-02

    Added

  • UMD-support
  • compilation using rollup.js

    Changed

  • changed default exports to normal exports for better compatibility
  • renamed Options to LoggerOptions
  • moved types to exported types namespace:
  • interface LoggerOptions
  • class Style
  • interface StyleInterface
  • type LogFunctionFactory
  • type LogFunction

    Fixed

  • added ComponentLogger to the documentation

    0.3.0 - 2020-09-01

    0.3.0-7 - 2020-08-31

Added

  • logo
  • PlainLogger - a LogFunctionFactory for environments with no color support:
import { PlainLogger } from '@fliegwerk/logsemts';

const loggers = [
PlainLogger(), // a LogFunction to log into the browser dev tools
PlainLogger({ logFunction: myFunction }) // use myFunction instead of console.log
];
  • WebhookLogger - a LogFunctionFactory to send serialized form of message to a specific web address in a POST request
import { WebhookLogger } from '@fliegwerk/logsemts';

const loggers = [
// sends a serialized JSON form of the message to the specified address
WebHookLogger({ address: 'http://localhost:8080' })
];
  • documentation of library concept to the README.md

0.3.0-6 - 2020-08-27

0.3.0-5 - 2020-08-27

0.3.0-4 - 2020-08-27

0.3.0-3 - 2020-08-27

0.3.0-2 - 2020-08-27

0.3.0-1 - 2020-08-27

Changed

  • npm publishing logic

0.3.0-0 - 2020-08-27

Breaking changes

  • made BrowserLogger a LogFunctionFactory (() => LogFunction) for consistency.

Upgrade instructions: To upgrade, replace BrowserLogger with BrowserLogger() in your code.

Added

  • ChalkLogger - a chalk based logger for NodeJS environments:
import { ChalkLogger } from '@fliegwerk/logsemts';
import chalk from 'chalk';

const loggers = [
ChalkLogger(chalk) // generates a new LogFunction using the chalk object
];
  • Logger.getComponentLogger - replaces Logger.getSubsystemLogger
  • serialize() and deserialize() - serializer that supports cyclic structures (a['b']['a'] === a) for sending objects in logs over network
  • better CI release automation

Changed

  • moved BrowserLogger.ts to src/loggers folder
  • updated BrowserLogger documentation
  • Terminology: subsystem => component
  • documentation style
  • enhanced documentation

Deprecated

  • Logger.getSubsystemLogger - use Logger.getComponentLogger instead

0.2.0 - 2020-08-26

Added

  • documentation
  • README
  • Coverage reporting to coveralls.io
  • keywords to package.json

0.1.4 - 2020-08-26

Added

  • CHANGELOG (using the fliegwerk CHANGELOG tool)

Changed

  • removed unnecessary files from npm package
  • updated dependencies

0.1.3 - 2020-06-14

Fixed

  • package issues

0.1.2 - 2020-06-14

Fixed

  • package issues

v0.1.1 - 2020-08-26

Initial prerelease.