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

Mute log record emission through Environment Variables #175

Closed
marcellodesales opened this issue Oct 20, 2014 · 2 comments
Closed

Mute log record emission through Environment Variables #175

marcellodesales opened this issue Oct 20, 2014 · 2 comments

Comments

@marcellodesales
Copy link

Hi there,

I was looking for a way to disable a given record to be emitted depending on its value. Is this possible???

My requirement is as follows:

Component A

  • require("bunyan");

Component B

  • Is composed by Component A
  • require("bunyan");

Components A and B have their own logging settings. Considering Component A is a shared library, I want to be able to disable records to be logged from Component B, depending on the properties of the logs from Component A, say, "component".

I'm thinking about something like this... Given the record:

{ name: "my app",
   component: "componentA"
   ...
}

I want to be able to remove disable the logging specifically from this using environment variables on Component B like the one below:

{{{
process.env.BUNYAN_DISABLE_REC_component = "ComponentA".
}}}

thanks!
Marcello

marcellodesales added a commit to marcellodesales/node-bunyan that referenced this issue Oct 21, 2014
This commit adds the function that initially fixes trentm#175 by disabling the
record being emitted. Requirements are described in the issue trentm#175.

*	modified:   lib/bunyan.js
- Adding a helper method to disable objects by properties

*	new file:   test/log-env-disabled.test.js
- Adding the disable test case by setting the environment var before loading
  the record.
marcellodesales added a commit to marcellodesales/node-bunyan that referenced this issue Oct 21, 2014
…ect.properties notation

This will exercise the case of references using the dot notation for the fix trentm#175.

*	modified:   test/log-env-disabled.test.js
- Adding a new env variable
- Adding the test case using the object.
@marcellodesales marcellodesales changed the title Disable logging depending on record's property value through Environment Variables Mute log record emission through Environment Variables Oct 21, 2014
@marcellodesales
Copy link
Author

Just noticed that the current version of the pull request may interfere with matching records from any app. I'm thinking I can add a prefix for the "name" of used for the record.

process.env.BUNYAN_DISABLE_REC_myapp.component=web

Where:

  • myapp = is the record.name value
  • component = is the record.component value.

That way, we can restrict the value that is "muted".

@trentm
Copy link
Owner

trentm commented Feb 3, 2016

Thanks for the issue. See my comments on #176.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants