Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Disabling INFO and WARN std::cerr #4

Closed
springmeyer opened this issue Jul 25, 2013 · 10 comments
Closed

Disabling INFO and WARN std::cerr #4

springmeyer opened this issue Jul 25, 2013 · 10 comments

Comments

@springmeyer
Copy link

Ideally, for node-osrm, there could be a way to disable this OSRM output so that meaningful logging could be controlled by the application calling into node-osrm

@DennisOSRM
Copy link
Contributor

Yes, makes sense.

@DennisOSRM
Copy link
Contributor

I'll expose a parameter to the library constructor that allows you to mute the logging. Does that make sense to what you have in mind?

@springmeyer
Copy link
Author

Yes. Was thinking silent by default and then verbose mode can be turned on. Plan to model this in node-osrm around how node-sqlite3 works.

@DennisOSRM
Copy link
Contributor

k, cool. Will dig a bit into node-sqlite3 to get a better impression.

@springmeyer
Copy link
Author

node-sqlite has db.on('trace'.. and db.on('profile'.. events you can hook into:

And node-blend has a third arg that is passed to callbacks (which were run in the thread pool) that provides an array of warnings:

These are candidates for how to design ways to get more debugging info. But, on further thought I think this is overkill for now in terms of node-osrm. Just being able to mute things sounds just fine for now!

@DennisOSRM
Copy link
Contributor

the current plan is to have a policy singleton that describes if logging is muted or not. And then a simple object that overrides std::ostringstreamoperator<< and which collects output. On destruction, it writes stuff to console. Usage will then be similar to Log().Get(logWarning) << "important message";

@springmeyer
Copy link
Author

okay, sounds good. And familiar to the new boost log and the mapnik debug framework

@DennisOSRM
Copy link
Contributor

Right, unfortunately the boost log library is not yet old enough to have trickled down into current linux distros.

@DennisOSRM
Copy link
Contributor

This is now implement in Project-OSRM/osrm-backend@44eed92. The default is that logging is disabled. To enable, toggle the that of the LogPolicy singleton class:

LogPolicy::GetInstance().Unmute();

Likewise .Mute() silences any output. Logging messages is as easy as

SimpleLogger().Write() << "super informative message goes here";

whereas .Write() takes a parameter to indicate logging level:

  • logINFO (default)
  • logWARNING
  • logDEBUG

@springmeyer
Copy link
Author

fantastic, tests for node-osrm now run cleanly and without noise :)

screen shot 2013-08-08 at 2 26 23 pm

The blue ones are pending, see #8 for details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants