@zenvia/logger 1.5.0 → 1.6.2

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.
@@ -0,0 +1,38 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ - push
8
+ - pull_request
9
+
10
+ jobs:
11
+ test:
12
+
13
+ runs-on: ubuntu-latest
14
+
15
+ strategy:
16
+ matrix:
17
+ node-version: [18.x]
18
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
19
+
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v3
23
+ - name: Use Node.js ${{ matrix.node-version }}
24
+ uses: actions/setup-node@v3
25
+ with:
26
+ node-version: ${{ matrix.node-version }}
27
+ cache: 'npm'
28
+ - name: Install dependencies
29
+ run: npm ci
30
+ - name: Run lint
31
+ run: npm run lint
32
+ - name: Run test
33
+ run: npm test
34
+ - name: Coveralls
35
+ uses: coverallsapp/github-action@v2
36
+ with:
37
+ github-token: ${{ secrets.GITHUB_TOKEN }}
38
+ path-to-lcov: ${{ github.workspace }}/coverage/lcov.info
@@ -0,0 +1,42 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 18
18
+ - name: Install dependencies
19
+ run: npm ci
20
+ - name: Run lint
21
+ run: npm run lint
22
+ - name: Run test
23
+ run: npm test
24
+ - name: Coveralls
25
+ uses: coverallsapp/github-action@v2
26
+ with:
27
+ github-token: ${{ secrets.GITHUB_TOKEN }}
28
+ path-to-lcov: ${{ github.workspace }}/coverage/lcov.info
29
+
30
+ publish-npm:
31
+ needs: build
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - uses: actions/checkout@v3
35
+ - uses: actions/setup-node@v3
36
+ with:
37
+ node-version: 18
38
+ registry-url: https://registry.npmjs.org/
39
+ - run: npm ci
40
+ - run: npm publish
41
+ env:
42
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -7,7 +7,7 @@ A wrapper for [Winston](https://github.com/winstonjs/winston) Logging [Node.js](
7
7
  [![Coverage Status](https://coveralls.io/repos/github/zenvia/zenvia-logger-node/badge.svg?branch=master)](https://coveralls.io/github/zenvia/zenvia-logger-node?branch=master)
8
8
  [![Dependencies](https://img.shields.io/david/zenvia/zenvia-logger-node.svg)](https://david-dm.org/zenvia/zenvia-logger-node)
9
9
 
10
- [![Twitter Follow](https://img.shields.io/twitter/follow/ZenviaMobile.svg?style=social)](https://twitter.com/intent/follow?screen_name=ZenviaMobile)
10
+ [![Twitter Follow](https://img.shields.io/twitter/follow/ZENVIA_.svg?style=social)](https://twitter.com/intent/follow?screen_name=ZENVIA_)
11
11
 
12
12
 
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenvia/logger",
3
- "version": "1.5.0",
3
+ "version": "1.6.2",
4
4
  "description": "A wrapper for Winston Logging Node.js library that formats the output on STDOUT as Logstash JSON format.",
5
5
  "license": "MIT",
6
6
  "main": "./src/index",
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "app-root-dir": "^1.0.2",
36
- "cls-rtracer": "^2.6.0",
37
- "winston": "^3.3.3"
36
+ "cls-rtracer": "^2.6.3",
37
+ "winston": "^3.11.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "chai": "^4.2.0",
package/src/index.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- import logger from './lib/logger';
2
- import middleware from './middleware/trace';
3
-
4
- export default logger;
5
- export const traceMiddleware = middleware();
1
+ export { default } from './lib/logger';
2
+ export { default as traceMiddleware } from './middleware/trace';
@@ -1,3 +1,9 @@
1
- declare const traceMiddleware: () => (req: IncomingMessage, res: ServerResponse, next: (err?: any) => void) => void;
1
+ import rTracer from 'cls-rtracer';
2
2
 
3
- export default traceMiddleware;
3
+ declare const traceMiddleware: () =>
4
+ ReturnType<typeof rTracer.expressMiddleware> |
5
+ ReturnType<typeof rTracer.fastifyPlugin> |
6
+ typeof rTracer.hapiPlugin |
7
+ ReturnType<typeof rTracer.koaMiddleware>;
8
+
9
+ export default traceMiddleware;
@@ -70,6 +70,21 @@ describe('Logger test', () => {
70
70
  JSON.parse(actualOutput).should.be.deep.equal(expectedOutput);
71
71
  });
72
72
 
73
+ it('should remove attributes that are log functions, leaving only the @timestamp, application, message and level fields', () => {
74
+ logger.info('some message', { field1: () => {} });
75
+ const expectedOutput = {
76
+ '@timestamp': '2018-06-05T18:20:42.345Z',
77
+ '@version': 1,
78
+ application: 'application-name',
79
+ host: os.hostname(),
80
+ message: 'some message',
81
+ level: 'INFO',
82
+ };
83
+
84
+ const actualOutput = stdMocks.flush().stdout[0];
85
+ JSON.parse(actualOutput).should.be.deep.equal(expectedOutput);
86
+ });
87
+
73
88
  it('should log @timestamp, application, message, level and environment fields', () => {
74
89
  process.env.NODE_ENV = 'test';
75
90
  logger.info('some message');
package/.travis.yml DELETED
@@ -1,27 +0,0 @@
1
- language: node_js
2
-
3
- node_js:
4
- - 12
5
-
6
- before_script:
7
- - npm ci
8
-
9
- script:
10
- - npm run lint
11
- - npm test
12
-
13
- after_success:
14
- - npm run test:coveralls
15
-
16
- deploy:
17
- provider: npm
18
- email: $NPM_EMAIL
19
- api_key: $NPM_TOKEN
20
- skip_cleanup: true
21
- on:
22
- tags: true
23
-
24
- notifications:
25
- email:
26
- recipients:
27
- - apisupport@zenvia.com