Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't omit the file path altogether #53

Open
dandv opened this issue Jul 12, 2018 · 2 comments
Open

Can't omit the file path altogether #53

dandv opened this issue Jul 12, 2018 · 2 comments

Comments

@dandv
Copy link
Contributor

dandv commented Jul 12, 2018

For certain messages, it's not interesting where they originate from (file:line). One example would be startup messages:

logger.info("We're up and running");  // the filepath:line is not interesting

Fortunately, though this is undocumented, .addTransform also receives the file:line as an object. I've tried adding a transform to suppress the line, but if it returns the empty string, the file:line is still output:

import logger from 'bristol';
logger.addTarget('console').withFormatter('human');

logger.addTransform(e => e.file && e.line ? '' : e);

logger.info('Started!');  // [2018-07-12 16:19:36] INFO: Started (file:///...:6)

Returning a whitespace is better, though because the file:path object is the first passed on to transform functions, this will lead to an extra whitespace in the middle of your output:

logger.addTransform(e => e.file && e.line ? ' ' : e);

logger.info('Note double space');  // [2018-07-12 16:28:35] INFO:   Note double space
@dandv
Copy link
Contributor Author

dandv commented May 26, 2019

@MarkHerhold: does Palin supports hiding the source of the message for individual log calls, rather than for all of them?

@MarkHerhold
Copy link
Contributor

@dandv It does not - just all of them.

However, I would like to point out that if you specify your project's root folder option with palin, the paths become very short which may be sufficient for you.

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

No branches or pull requests

2 participants