-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 325aa10
Showing
25 changed files
with
1,270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"root": true, | ||
"extends": [ "@bonniernews" ], | ||
"rules": { | ||
"new-cap": 0, | ||
"prefer-arrow-callback": "off", | ||
"quotes": [ "error", "single", { "avoidEscape": true } ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: default | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [ 18, latest ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm i | ||
- run: npm run build | ||
- run: npm run test:lcov | ||
- name: Coveralls | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
flag-name: run-${{ matrix.node-version }} | ||
parallel: true | ||
|
||
finish: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Coveralls Finished | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
parallel-finished: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Dependency directory and npm log | ||
node_modules | ||
npm-debug.log | ||
tmp | ||
|
||
# Code coverage results | ||
/coverage | ||
coverage* | ||
|
||
# Built package | ||
/*.tgz | ||
|
||
# Project files | ||
.tern-port | ||
.tern-project | ||
.idea | ||
*.iml | ||
.vscode | ||
|
||
# Compiled client resources | ||
/public/ | ||
|
||
# Revision file | ||
config/_revision | ||
|
||
# OS X | ||
.DS_Store | ||
|
||
# vim | ||
*.swp | ||
*.swo | ||
|
||
# eslint | ||
.eslintcache | ||
|
||
lib/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recursive": true, | ||
"exit": true, | ||
"require": ["./test/helpers/setup.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Zerodep | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# pino applicationinsights transport | ||
|
||
Forward pino logger to Application Insights. | ||
|
||
## Usage | ||
|
||
```js | ||
import { pino } from 'pino'; | ||
import build from '@zerodep/pino-applicationinsights'; | ||
|
||
const transport = build({ | ||
track(chunk) { | ||
const { time, severity, msg: message, properties, exception } = chunk; | ||
this.trackTrace({ time, severity, message, properties }); | ||
if (exception) this.trackException({ time, exception, severity }); | ||
}, | ||
connectionString, | ||
config: { maxBatchSize: 1 }, | ||
}); | ||
|
||
const logger = pino({ level: 'trace' }, transport); | ||
``` | ||
|
||
## API | ||
|
||
### `build(opts[, TelemetryTransformation]) => Stream` | ||
|
||
Build transport stream function. | ||
|
||
- `opts`: | ||
* `track(chunk)`: track function called with Telemetry client context | ||
* `connectionString`: Application Insights connection string or instrumentation key | ||
* `config`: optional Application Insights Telemetry client config | ||
* `destination`: optional destination stream, makes build ignore the above options | ||
* `ignoreKeys`: optional pino ignore keys, defaults to `['hostname', 'pid', 'level', 'time', 'msg']` | ||
- `TelemetryTransformation`: optional transformation stream extending [TelemetryTransformation](#class-telemetrytransformationoptions-config) | ||
|
||
### `class TelemetryTransformation(options[, config])` | ||
|
||
Telemetry transformation stream. Transforms pino log record to Telemetry:ish object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"name": "@zerodep/pino-applicationinsights", | ||
"version": "0.0.1", | ||
"description": "Pino applicationinsights transport", | ||
"type": "module", | ||
"module": "./src/log-transport.js", | ||
"exports": { | ||
"types": "./types", | ||
"import": "./src", | ||
"require": "./lib" | ||
}, | ||
"engines": { | ||
"node": ">= 16" | ||
}, | ||
"scripts": { | ||
"test:ts": "mocha --config test/typescript/.mocharc.json", | ||
"pretest": "npm run build", | ||
"test": "mocha", | ||
"posttest": "npm run test:ts && npm run lint", | ||
"lint": "eslint . --cache", | ||
"prepublishOnly": "npm run build", | ||
"cov:html": "c8 -n src -r html -r text mocha", | ||
"test:lcov": "c8 -n src -r lcov -r text mocha", | ||
"build": "rollup -c" | ||
}, | ||
"keywords": [ | ||
"pino", | ||
"transport", | ||
"applicationinsights", | ||
"fake", | ||
"mock" | ||
], | ||
"author": { | ||
"name": "Zerodep AB", | ||
"url": "https://github.com/zerodep" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@bonniernews/eslint-config": "^1.0.1", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@types/chai": "^4.3.9", | ||
"@types/mocha": "^10.0.3", | ||
"@types/node": "^16.18.60", | ||
"applicationinsights": "^2.9.0", | ||
"c8": "^8.0.1", | ||
"chai": "^4.3.10", | ||
"chronokinesis": "^6.0.0", | ||
"eslint": "^8.52.0", | ||
"mocha": "^10.2.0", | ||
"nock": "^13.3.7", | ||
"pino": "^8.16.1", | ||
"pino-abstract-transport": "^1.1.0", | ||
"rollup": "^4.2.0", | ||
"ts-node": "^10.9.1" | ||
}, | ||
"peerDependencies": { | ||
"applicationinsights": ">= 2.9", | ||
"pino-abstract-transport": "=> 1.1" | ||
}, | ||
"optionalDependencies": { | ||
"nock": "*" | ||
}, | ||
"files": [ | ||
"lib/*.cjs", | ||
"src/*.js", | ||
"types" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
|
||
export default [ { | ||
input: './src/index.js', | ||
external: [ | ||
'node:stream', | ||
'applicationinsights', | ||
'pino-abstract-transport', | ||
], | ||
plugins: [ | ||
commonjs(), | ||
], | ||
output: [ | ||
{ | ||
file: './lib/index.cjs', | ||
exports: 'named', | ||
format: 'cjs', | ||
footer: 'module.exports = Object.assign(exports.default, exports);', | ||
}, | ||
], | ||
}, { | ||
input: './src/fake-applicationinsights.js', | ||
external: [ | ||
'node:zlib', | ||
'applicationinsights', | ||
'nock', | ||
], | ||
plugins: [ | ||
commonjs(), | ||
], | ||
output: [ | ||
{ | ||
file: './lib/fake-applicationinsights.cjs', | ||
exports: 'named', | ||
format: 'cjs', | ||
}, | ||
], | ||
} ]; |
Oops, something went wrong.