Skip to content

Commit

Permalink
fix(logger): module pass error
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed May 7, 2021
1 parent 7cb849f commit 9bdaee3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion example/hoth-quickstart/src/controller/app/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default class AppController {
private readonly service!: Calculator;

@Hook('preHandler')
async preHandler() {
async preHandler(req: FastifyRequest<requestGeneric>) {
req.module = 'test';
console.log('in controller');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/logger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function (options: LoggerOptions) {
parameters: request.parameters,
headers: request.headers,
ip: request.ip,
module: request.product,
module: request.module,
product: request.product,
logid: request.logid,
notices: request[noticeSym],
Expand Down
5 changes: 5 additions & 0 deletions packages/logger/src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {defaultLevels} from './constants';
import {getTime} from './getTime';

const metadata = Symbol.for('pino.metadata');
const isDevelopment = process.env.NODE_ENV === 'development';

export default function (streamsArray) {
let counter = 0;
Expand Down Expand Up @@ -63,6 +64,10 @@ export default function (streamsArray) {
stream = info.level >= 40 ? process.stderr : process.stdout;
}

if (isDevelopment) {
console.log(info.result);
}

stream.write(info.result);
}

Expand Down

0 comments on commit 9bdaee3

Please sign in to comment.