ac-logger 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/index.js +8 -8
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ <a name="2.1.0"></a>
2
+
3
+ # [2.1.0](https://github.com/admiralcloud/ac-logger/compare/v2.0.1..v2.1.0) (2023-07-26 06:39:56)
4
+
5
+
6
+ ### Feature
7
+
8
+ * **App:** Add option to add more transporters | MP | [1b26ccf1bee9dde56545e51f767f03def84328b7](https://github.com/admiralcloud/ac-logger/commit/1b26ccf1bee9dde56545e51f767f03def84328b7)
9
+ You can init the logger with additional transporters
10
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
1
11
  <a name="2.0.1"></a>
2
12
 
3
13
  ## [2.0.1](https://github.com/admiralcloud/ac-logger/compare/v2.0.0..v2.0.1) (2023-07-26 06:22:11)
package/index.js CHANGED
@@ -4,14 +4,7 @@ const path = require('path')
4
4
 
5
5
  const { createLogger, format, transports, addColors } = require('winston');
6
6
 
7
- module.exports = (config) => {
8
- const prefixFields = _.get(config, 'prefixFields', [])
9
- const timestampFormat = _.get(config, 'timestampFormat', 'YYYY-MM-DD HH:mm:ss')
10
- const level = _.get(config, 'level', (process.env.NODE_ENV === 'production' ? 'info' : 'verbose'))
11
- const headLength = _.get(config, 'headLength', 80)
12
- const padLength = _.get(config, 'padLength', 12)
13
- const customLevels = _.get(config,'customLevels')
14
-
7
+ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss', level = (process.env.NODE_ENV === 'production' ? 'info' : 'verbose'), headLength = 80, padLength = 12, customLevels, additionalTransports } = {}) => {
15
8
  const precisionMap = [
16
9
  { precision: 1e6, name: 'ms' },
17
10
  { precision: 1e3, name: 'µs' },
@@ -64,6 +57,13 @@ module.exports = (config) => {
64
57
  const acLogger = createLogger(logConfig)
65
58
  if (_.get(customLevels, 'colors')) addColors(_.get(customLevels, 'colors'))
66
59
 
60
+ // Array of objects with type (e.g. File) and options for that type
61
+ if (_.size(additionalTransports)) {
62
+ _.forEach(additionalTransports, transport => {
63
+ acLogger.add(new transports[transport.type](transport.options))
64
+ })
65
+ }
66
+
67
67
  if (process.env.NODE_ENV === 'test') {
68
68
  acLogger.add(new transports.File({
69
69
  filename: 'test.log',
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mark Poepping (https://www.admiralcloud.com)",
4
4
  "license": "MIT",
5
5
  "repository": "admiralcloud/ac-logger",
6
- "version": "2.0.1",
6
+ "version": "2.1.0",
7
7
  "dependencies": {
8
8
  "lodash": "^4.17.21",
9
9
  "moment": "^2.29.4",