@bogeychan/elysia-logger
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -19,1 +19,2 @@ import Elysia from 'elysia'; | ||
export type { InferContext } from './types'; | ||
export { pino } from 'pino'; |
@@ -29,9 +29,13 @@ import pino from 'pino'; | ||
delete options.autoLogging; | ||
let log; | ||
let app = new Elysia({ | ||
name: '@bogeychan/elysia-logger' | ||
}).derive((ctx) => ({ | ||
log: typeof options.customProps === 'function' | ||
? this.child(options.customProps(ctx)) | ||
: this | ||
})); | ||
name: '@bogeychan/elysia-logger', | ||
seed: options | ||
}).derive((ctx) => { | ||
log = | ||
typeof options.customProps === 'function' | ||
? this.child(options.customProps(ctx)) | ||
: this; | ||
return { log }; | ||
}); | ||
if (autoLogging) { | ||
@@ -43,3 +47,3 @@ app = app | ||
.onResponse((ctx) => { | ||
if (ctx.log.level == 'silent') { | ||
if (log.level == 'silent') { | ||
return; | ||
@@ -53,3 +57,3 @@ } | ||
ctx.store.responseTime = ctx.store.endTime - ctx.store.startTime; | ||
ctx.log.info(ctx); | ||
log.info(ctx); | ||
}); | ||
@@ -61,1 +65,2 @@ } | ||
export * from './config'; | ||
export { pino } from 'pino'; |
{ | ||
"name": "@bogeychan/elysia-logger", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "A plugin for Elysia.js for logging using the pino library", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -118,7 +118,7 @@ # @bogeychan/elysia-logger | ||
logger({ | ||
autoLogging: true // default | ||
autoLogging: false // disabled | ||
autoLogging: true, // default | ||
autoLogging: false, // disabled | ||
autoLogging: { | ||
ignore(ctx) { | ||
return true // ignore logging for all requests | ||
return true; // ignore logging for requests based on condition | ||
} | ||
@@ -133,6 +133,2 @@ } | ||
## Author | ||
[bogeychan](https://github.com/bogeychan) | ||
## License | ||
@@ -139,0 +135,0 @@ |
@@ -86,11 +86,16 @@ import pino from 'pino'; | ||
let log: Logger; | ||
let app = new Elysia({ | ||
name: '@bogeychan/elysia-logger' | ||
}).derive((ctx) => ({ | ||
log: | ||
name: '@bogeychan/elysia-logger', | ||
seed: options | ||
}).derive((ctx) => { | ||
log = | ||
typeof options.customProps === 'function' | ||
? this.child(options.customProps(ctx)) | ||
: this | ||
})); | ||
: this; | ||
return { log }; | ||
}); | ||
if (autoLogging) { | ||
@@ -106,3 +111,3 @@ app = ( | ||
.onResponse((ctx) => { | ||
if (ctx.log.level == 'silent') { | ||
if (log.level == 'silent') { | ||
return; | ||
@@ -119,8 +124,8 @@ } | ||
ctx.log.info(ctx); | ||
log.info(ctx); | ||
}); | ||
// ! ctx.log is undefined or onError called twice for custom error... | ||
// ! log is undefined or onError called twice for custom error... | ||
// ? tested on elysia@0.7.17 | ||
// .onError((ctx) => { | ||
// ctx.log.error(ctx); | ||
// log.error(ctx); | ||
// }); | ||
@@ -139,1 +144,3 @@ } | ||
export { pino } from 'pino'; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21971
474
136