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
Use a logging library #202
Comments
There is always Boost logging somewhere near but it seems to be huge and slow to build. Something smaller would be preferrable (non-professional opinion). |
boost::log was only introduced in 1.54. This is a big minus. @zerebubuth, I can't remember the options we came up with at the hack weekend. |
There's google's logging library too. I've never used it, though, so I The MQ logging library is probably no good for now, as it currently depends
|
I forgot our library depends on Mapnik. I agree, that rules it out. log4cxx is another library mentioned, patterned after log4j. log4cxx is packaged on Ubuntu 12.04, 14.04 and FreeBSD google-glog is Google's. It is packaged on Ubuntu 14.04 and FreeBSD, but not Ubuntu 12.04. |
Maybe use something lighweight and header-only like https://github.com/gabime/spdlog , if you are going to use cppformat anyway #398 |
Another way is to use boost whenever possible, like https://github.com/alacarte-maps/alacarte (just switched from log4cpp to boost log) and https://github.com/Project-OSRM/osrm-backend (including logging, formatting, testing if needed). Performance and compilation time may suffer a little :) |
osmium::util::VerboseOutput might be of use here |
Per previous discussion, we need support for three levels of output - details (off by default), standard, and errors. We might also have additional debugging output with some compile-time flags (e.g. all COPY lines to postgres) |
This improves the logging output in several ways: * New logging functions log_debug/info/warn/error(). Almost all output now uses one of these functions. * Log messages start with timestamp. * Log messages of level warn/error are printed in red when logging to console. * New command line option: --log-level to set log level. Default is "info". The option -v, --verbose does the same as --log-level=debug. * New option --log-progress=true/false/auto. The default is `auto` which enables progress logging on the console and disables it when stderr has been redirected to a file. * Extra functions to log SQL commands/SQL COPY data. These can be activated by command line options --log-sql and --log-sql-data, respectively, instead of the compile time setting. Output is printed in blue when logging to console. Most log messages are in level "info" at the moment, so they are shown as before with the default settings. Many of these probably don't need to be shown in normal operation and can be downgraded to "debug". I'll leave this for a later commit. There are several places in the code where the output is updated on the screen while some longer process is running: * The code displaying regular updates of a counter in the expire code has been removed. Writing out the expire data doesn't take that long, so it isn't important to have this. Instead a log message is now generated. * The output of the objects being processed and the pending ways and relations output is now en/disabled by the `--log-progress` option. Otherwise it has not been touched. I'll leave cleaning that up for a later time. Some error reporting code has also been changed. Usually errors should be reported by throwing an exception that is then caught in the main() function and written out. The exception should contain the whole error message, sometimes additional logging lines are created before throwing the error. There is probably some more cleanup needed here. This introduces a new global object "the_logger". Otherwise we'd have to add the logger as parameter to a lot of functions! Fixes osm2pgsql-dev#202 Fixes osm2pgsql-dev#1246 Fixes osm2pgsql-dev#591
Currently everything prints out with fprintf. This makes it hard to change the verbosity.
Any thoughts?
@zerebubuth, do you think MapQuest/logging would be suited here?
The text was updated successfully, but these errors were encountered: