0.0.8 • Published 13 days ago

@nr1e/logging v0.0.8

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
13 days ago

Logging

NPM Version TypeScript Style Guide GitHub Actions

Provides a simple logging interface for typescript projects that adheres to the NR1E logging standard.

To install using pnpm

pnpm i @nr1e/logging-js

How to use

Initialize logging in your application.

import * as logging from '@nr1e/logging-js';

// Only needs to be performed once
logging.initialize({
    level: 'info',
    svc: 'my-service',
});

This only needs to be done once. Additional calls to initialize will have no effect.

In your modules, get a named logger

import * as logging from '@nr1e/logging-js';

const log = logging.getLogger('my-module');

To log a message

log.info('Just another day in the life of a logger');

To log a message with a context

log.info({foo: 'bar'}, 'Just another day in the life of a logger');

You can also log nested objects

log.info(
    {foo: 'bar', nested: {foo: 'bar'}},
    'Just another day in the life of a logger'
);

To log a message using string interpolation

log.info('Just another day in the life of a logger with %s', 'interpolation');

To log an error

catch (err) {
    log.error(err, 'An error occurred');
}

To log an error with additional context

catch (err) {
    log.error(err, {foo: 'bar'}, 'An error occurred');
}

Be aware, your error must be named 'err' in the context for the error to be logged.

Angular Projects

If you are trying to use this library with Angular, you will need to add the os-browserify package to your project.

pnpm i --save-dev os-browserify

Then add the following to your angular.json file inside compilerOptions

{
  ...
  compilerOptions: {
    ...
    "paths": {
      "os": [
        "./node_modules/os-browserify"
      ]
    }
  }
}
0.0.8-alpha.0

13 days ago

0.0.8

13 days ago

0.0.6-alpha.0

26 days ago

0.0.6-alpha.1

26 days ago

0.0.7-alpha.0

26 days ago

0.0.7

26 days ago

0.0.6

26 days ago

0.0.5-alpha.10

3 months ago

0.0.5

3 months ago

0.0.5-alpha.9

3 months ago

0.0.5-alpha.8

3 months ago

0.0.5-alpha.5

3 months ago

0.0.5-alpha.6

3 months ago

0.0.5-alpha.7

3 months ago

0.0.5-alpha.0

3 months ago

0.0.5-alpha.1

3 months ago

0.0.5-alpha.2

3 months ago

0.0.5-alpha.3

3 months ago

0.0.5-alpha.4

3 months ago

0.0.4-alpha.1

4 months ago

0.0.4-alpha.2

4 months ago

0.0.4-alpha.3

4 months ago

0.0.4

4 months ago

0.0.3-alpha.11

4 months ago

0.0.3-alpha.10

4 months ago

0.0.4-alpha.0

4 months ago

0.0.3

4 months ago

0.0.3-alpha.7

4 months ago

0.0.3-alpha.6

4 months ago

0.0.3-alpha.9

4 months ago

0.0.3-alpha.8

4 months ago

0.0.1-alpha.10

4 months ago

0.0.1-alpha.8

4 months ago

0.0.1-alpha.9

4 months ago

0.0.1

4 months ago

0.0.1-alpha.6

4 months ago

0.0.1-alpha.7

4 months ago

0.0.1-alpha.5

4 months ago

0.0.3-alpha.3

4 months ago

0.0.3-alpha.2

4 months ago

0.0.3-alpha.5

4 months ago

0.0.3-alpha.4

4 months ago

0.0.3-alpha.1

4 months ago

0.0.3-alpha.0

4 months ago

0.0.1-alpha.4

4 months ago

0.0.1-alpha.3

4 months ago

0.0.1-alpha.2

4 months ago