open-index/open-npm huggingface dataset:
npm package: @gigads/logger-client
Description: GDS Logger Client
Author: SR
Latest version: 0.3.1

# @GigaDS logger-client
Helper to log on DB from any NodeJS express-based server.

## Options object and defaults
```javascript
options = { 
  // pino-related options
  prettyPrint: false,                // non-mandatory

  // @gigads/logger-client specific options
  enableRouterLog: false,            // non-mandatory, enables pino-http logger on routes
  enableConsoleLog: false,           // non-mandatory, logs on output when log method is called
  enableDatabaseLog: false,          // non-mandatory, logs on database when log method is called
  databaseApiUrl: '',                // mandatory if enableDatabaseLog = true, url to logger server APIs
  databaseApiAuthToken: '',          // depends on your logger server, better if you use one. auth_token in headers
  nodeEnv: process.env.NODE_ENV,     // non-mandatory, NODE_ENV variable should be passed. defaults to 'undefined'
  defaultLogLevel: LogLevel.DEBUG,   // non-mandatory, default log level, defaults to 'debug'
  applicationName: 'myLoggingApp'    // who is logging
};
```

## Log levels
```javascript
LogLevel.TRACE
LogLevel.DEBUG
LogLevel.INFO
LogLevel.WARN
LogLevel.ERROR
Loglevel.FATAL
```

## How to
```javascript
const { loggerMiddleware, LogLevel } = require('@gigads/logger-client');
app.use(loggerMiddleware(options));
```

Then, in any app route, you can log with
```javascript
// req.logger.log(level, operation, message, extras);
req.logger.log(LogLevel.WARN, 'Cloning obj', 'obj was filled', {
  value: obj.field
});
```
or with any other helper (see below)

## API
### Generic log
```javascript
req.logger.log(level, operation, message, extras);
```
### Helpers
```javascript
req.logger.logTrace(operation, message, extras);
req.logger.logDebug(operation, message, extras);
req.logger.logInfo(operation, message, extras);
req.logger.logWarn(operation, message, extras);
req.logger.logException(operation, exception);
req.logger.logFatal(operation, exception);
```