0.0.2 • Published 2 years ago

@geniucode/chokidar v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

GeniuCode Logger

The purpose of this package is to have a central logger for working in different environments. Agnostic - It will be integrated into multiple external cloud log services, like Datadog, logz.io...

Install

npm i --save @geniucode/chokidar

API Documentation

On the entry point of the app

In each project a new folder called logger src/logger, and within it create a file called index.ts

import { logging } from '@geniucode/chokidar';

let envType = process.env.ENVIRONMENT || 'development'; // NOTICE | This might be different in core-libs
envType = envType === 'local' ? 'development' : envType;

const PACKAGE_NAME = 'common-services.sekur';

const options = {
  minLevels: {
    '': 'info',
    core: 'warn'
  },
  format: {
    addSplitterStrings: false
  },
  debug: {
    isEnabled: true
  }
};
const integrations = {};

export const logi = (moduleName?: string) => {
  moduleName = moduleName ? `${PACKAGE_NAME}.${moduleName}` : PACKAGE_NAME;
  return logging
    .configure(options, moduleName, envType, integrations)
    .getLogger();
};

Then, in each file that you want to log

// No need to add index.ts to the path, it is imported automatically as default
// ./logger change it depends on your relative path

import { logi } from './logger';
const logger = logi(__filename);

logger.info(`This is a demo info message`);
logger.error(`This is a demo error message`);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

Please see License File for more information.

0.0.2

2 years ago

0.0.1

4 years ago