Detalhes do pacote

advanced-logger

AlexeyPopovUA755MIT3.0.6

Advanced logger module extendable with plugins. Works in nodejs and browsers

logger, advanced-logger, logger-plugin, sumologic

readme (leia-me)

advanced-logger

Feature branch build npm version install size

Quality checks Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Maintainability Rating Reliability Rating Security Rating Technical Debt Vulnerabilities

Conventional Commits

FOSSA Status

What is it?

It is an extendable isomorphic log sending library written in TypeScript for javascript application in nodejs and browsers.

It can be extended with custom strategy ("when to send logs") and service ("where to send logs").

It does not restrict you with conventions, for example, existence of "logSeverity", "ErrorId" or "message" fields in log.

It supports any format of logs via custom serializer.

Features

  • :scream_cat: It works in browsers and nodejs
  • :articulated_lorry: It is able to send single logs and bundles of them to an external logger
  • It supports different log sending strategies:
    1. :alarm_clock: interval (for example, every 10 seconds)
    2. :loudspeaker: on request (only when you ask)
    3. :alarm_clock: :heavy_plus_sign: :loudspeaker: mixed ("interval" + "on request") (will be done soon)
    4. :steam_locomotive: :railway_car: :railway_car: :railway_car: on bundle size (for example, sends bundles of 100 logs)
    5. :toilet: instant (received 1 log -> sent 1 log)
  • :busts_in_silhouette: It is able to group duplicated logs in certain time interval (for rapid fire of the same logs)
  • :octopus: It is not afraid of circular links in log objects
  • :building_construction: It supports custom format for logs (custom serializer)
  • :dart: It supports different remote logger endpoints (SumoLogic, Loggly and Elasticsearch). Who is the next? ᕙ(ಠ.ಠ)ᕗ

Runtime environment support :running_woman:

Builds are generated as ES2015 bundles for nodejs and browser environments.

:robot: NodeJS - tested on latest lts

:globe_with_meridians: Browser - all latest browsers, that support ES2015 JS.

Documentation

Complete documentation and examples can be found here:

Advanced Logger's Homepage

NPM package link

Simplest usage

Now, the boring part :nerd_face:

Installation

Axios is a required peer dependency. It means that axios is not bundled into logger package, but required to be installed.

As a dependency in a npm project:

npm i --save advanced-logger axios
import {AdvancedLogger, service, strategy} from 'advanced-logger';
// or
const {AdvancedLogger, service, strategy} = require('advanced-logger');

As script tags with CDN:

<!--minified-->
<script src="https://cdn.jsdelivr.net/npm/axios@latest/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/advanced-logger@latest/dist/browser/advanced-logger.browser.min.js"></script>
<!--dev version-->
<script src="https://cdn.jsdelivr.net/npm/axios@latest/dist/axios.js"></script>
<script src="https://cdn.jsdelivr.net/npm/advanced-logger@latest/dist/browser-debug/advanced-logger.browser.js"></script>

Configuration

Lets initiate a logger that sends all logs instantly to Sumologic service.

import {AdvancedLogger, service, strategy} from 'advanced-logger';

const defaultLogConfig = {
    UserAgent: window.userAgent,
    Channel: "my-company",
    BuildVersion: 123,
    Platform: "browser",
    Severity: "DEBUG",
    Data: "",
    Timestamp: "",
    Message: "",
    Category: ""
};

const serviceConfig = {
    url: "https://www.google.nl",
    sourceName: "advancedLoggerTest",
    host: "advanced-logger",
    sourceCategory: "MY/SUMO/namespace",
    method: "POST"
};

const config = {serviceConfig, defaultLogConfig};

const logger = new AdvancedLogger({
    service: new service.SumologicService(config),
    strategy: new strategy.InstantStrategy()
});

logger.log({test: "instant log u1"}); // sends log message :rocket:
logger.log({test: "instant log u2"}); // sends log message :rocket:
logger.log({test: "instant log u3"}); // sends log message :rocket:

Upgrading between breaking changes

2.x to 3.x

  • Install axios to your project or just keep using it if it is already installed
  • Logger is compiled to ES2015 JS target. If your project requires support of old browsers and nodejs, please, make sure that you transpile and add necessary pollyfills to the build

changelog (log de mudanças)

Changelog

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

3.0.6 (2023-05-22)

Bug Fixes

  • npm: npmignore file should not exclude d.ts from dist directory (9d6f7a8)

3.0.5 (2022-06-03)

Bug Fixes

  • github: use proper caching configuration for npm (9c4c925)

3.0.4 (2022-05-22)

3.0.3 (2022-05-07)

Bug Fixes

  • npm: update lock file to fix the installation process (0b0c31e)

3.0.2 (2022-04-10)

3.0.1 (2022-04-09)

Bug Fixes

  • sonar: fix sonar TS configuration (02a928f)

3.0.0 (2022-04-09)

⚠ BREAKING CHANGES

  • upgrade: types, http request library

Features

Bug Fixes

  • readme: update old shields (19e5924)

2.1.4 (2020-09-02)

Bug Fixes

  • deps: update dependency lodash to v4.17.19 (6099c5d)
  • deps: update dependency lodash to v4.17.20 (34c9c68)
  • deps: update dependency whatwg-fetch to v3.1.0 (a7b77ff)
  • deps: update dependency whatwg-fetch to v3.2.0 (332bbde)
  • deps: update dependency whatwg-fetch to v3.4.0 (ec5d843)

2.1.3 (2020-06-07)

Bug Fixes

  • sonar: fix sonar authentication (0bd6958)

2.1.2 (2020-02-12)

Bug Fixes

  • types: get the TS types back (f4daf6d)

2.1.1 (2020-02-12)

2.1.0 (2020-02-09)

Features

  • service: implement ability to use and extend BaseRemoteService (9c76c51)

Bug Fixes

  • serializer: serializer should return string type (6755b2e)

2.0.7 (2019-12-14)

Bug Fixes

  • coverage: bring test coverage back (00ae954)

2.0.6 (2019-09-20)

2.0.5 (2019-08-17)

Bug Fixes

  • deps: update dependency lodash to v4.17.13 [security] (248a8e3)

2.0.4 (2019-04-29)

Bug Fixes

  • strategy: throttle instead of debounce (47777fa)

2.0.3 (2019-04-25)

Bug Fixes

  • fetch: window.fetch should be bound to window (c78728f)

2.0.2 (2019-04-25)

Bug Fixes

  • audit: audit autofix (89798d6)
  • sonar: sonar warnings fixes (ad96260)
  • target: library target fix for browser mode (d52e8c7)

2.0.1 (2019-03-24)

Bug Fixes

  • coverage: coverage report folder should not be cleaned (bdf5490)

2.0.0 (2019-03-24)

Features

  • build: bundle correction for webpack browser build (85bec1b)

BREAKING CHANGES

  • build: new entry point for bundlers

1.4.1 (2019-02-21)

1.4.0 (2019-02-10)

Bug Fixes

  • sonar: fix of unsupported branch names in sonarcloud (01fda69)
  • sonar: unsupported branch names in sonarcloud cannot be fixed (3b2d313)
  • types: header object type correction (4299537)
  • types: response mock should be casted to the correct type (28afbbd)

Features

  • service: elastic search service implementation (3bdffa1)

Performance Improvements

  • build: webpack build speed should be 4 times faster (d6d5f13)

1.3.0 (2018-12-25)

Features

  • serializer: support of custom serializer (d8a20d3)

1.2.2 (2018-12-07)

1.2.1 (2018-12-07)

Bug Fixes

  • polyfill: fetch polyfill should not be invasive (75f946c)

1.2.0 (2018-12-05)

Features

  • polyfill: fetch polyfill was added in order to support ie10 - ie11 (5345d78)
  • workflow: configuration for commit linting (df16e32)

1.1.15 (2018-12-01)

Bug Fixes

  • build: Build cleaning script (572ec30)

1.1.14 (2018-11-11)

1.1.13 (2018-11-05)

1.1.12 (2018-11-05)

1.1.11 (2018-11-05)

1.1.10 (2018-11-05)

1.1.9 (2018-10-22)

1.1.8 (2018-10-17)

1.1.7 (2018-09-26)

1.1.6 (2018-09-26)

1.1.5 (2018-09-12)

1.1.4 (2018-09-12)

1.1.3 (2018-09-12)

1.1.2 (2018-09-12)

1.1.1 (2018-09-11)

1.1.0 (2018-09-11)

1.0.10 (2018-09-06)

1.0.9 (2018-08-22)

1.0.8 (2018-08-22)

1.0.7 (2018-06-21)

1.0.6 (2018-05-04)

1.0.5 (2018-05-04)

1.0.4 (2018-02-09)

1.0.3 (2018-02-09)

1.0.2 (2017-11-17)

1.0.1 (2017-11-03)