Skip to content

Conversation

@kartikp36
Copy link
Member

No description provided.

@kartikp36 kartikp36 requested a review from harsilspatel August 5, 2021 20:18
Copy link
Contributor

@harsilspatel harsilspatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost all logs follow a pattern, logger.debug(<object>, "<module>, <fn>, <object>");
Find if there's an easy way to get module and fn then abstract that logic into a function, say getLogId then use it like so

logger.debug(<object>, `${getLogId()} <object>`);```


import * as service from "./service";
import { logger } from "./index";
import path from "path";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well tried but this implementation introduces even more repetitive code. The trick is to either parse it from stack trace (some examples on SO) or use something like https://github.com/felixge/node-stack-trace

@kartikp36 kartikp36 requested a review from harsilspatel August 13, 2021 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants