-
Notifications
You must be signed in to change notification settings - Fork 826
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
Make better debug print system #937
Comments
Something started in debug-plugins branch: https://github.com/mapnik/mapnik/tree/debug-plugins |
@springmeyer now when ENABLE_LOG is True (or DEBUG = True) you can turn on and off debugging in datasources (useful when you want to check everything in pre-production environment where you build in release mode, but you want debug output) also, i've enable statistics for datasources when ENABLE_STATS is True |
I'm testing a full std::ostream replacement instead of using std::clog, where you can define where to output the logs, file or console, and control the formatting. |
looking good (I'll comment more when I have time to compile/test). Also, yes def a good idea to support writing not only to stderr but also files, etc! Also, just a heads up that sometime soon (next week or two) I want to work on merging master...move_bind_logic_to_layer. I realize this could have many conflicts so likely best to have your debug work hit master first. |
also another heads up - we need to replace the timer with boost::timer/chrono at some point so the timer can be used on windows - I presume the interface can be kept the same however so it should be no problem using it for now. |
yeah, makes sense. i would like to work on this a little more to define at least a logging class based on the ostream. i will try to merge back the branch at start of the next week (not later than wednesday). |
@kunitoki - logging class sounds good. re: merging, I would prefer that all commits are collapsed into a single commit and then applied to master rather than actually merging as is (which interleaves). Sound good? The poor mans approach to this is:
|
ok will do like you suggest, thanx ! btw, isn't that the purpose of the rebase command (collect the changes as one big patch file to apply to another git tree) ? |
Yes, its like rebasing. That is why I said "poor mans" approach. The only benefit to the poor mans approach is that it leaves the existing history of the first branch untouched (which can be useful for reviewing until the work is done). |
Just had a chance to compile and test both the STATS and LOG modes independently - very nice! |
check if this works for you: https://gist.github.com/2311551 |
I vastly improved the logging facilities. There are a few things to discuss:
other things to do:
|
wow. amazing work. |
compiling without logging I get compile errors because diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp
index 3abe245..a556ceb 100644
--- a/include/mapnik/debug.hpp
+++ b/include/mapnik/debug.hpp
@@ -23,6 +23,14 @@
#ifndef MAPNIK_DEBUG_HPP
#define MAPNIK_DEBUG_HPP
+#ifdef MAPNIK_DEBUG
+#define MAPNIK_DEBUG_AS_BOOL true
+#else
+#define MAPNIK_DEBUG_AS_BOOL false
+#endif
+
+#ifdef MAPNIK_LOG
+
// mapnik
#include <mapnik/global.hpp>
@@ -39,12 +47,6 @@
#include <ostream>
#include <fstream>
-#ifdef MAPNIK_DEBUG
-#define MAPNIK_DEBUG_AS_BOOL true
-#else
-#define MAPNIK_DEBUG_AS_BOOL false
-#endif
-
#ifndef MAPNIK_LOG_FORMAT
#error Must run configure again to regenerate the correct log format string. See LOG_FORMAT_STRING scons option.
#endif
@@ -124,4 +126,6 @@ namespace mapnik {
}
-#endif
+#endif // MAPNIK_LOG
+
+#endif // MAPNIK_DEBUG_HPP |
ah sure. will fix it asap thanx ps. the error when MAPNIK_LOG_FORMAT is not defined should go away as we release. or eventually i could pick up a default in the file itself. |
we now need to define the policies on how to handle notices / warnings / errors and their respective strictness (when and if they throw at all). |
now hitting (with clang++):
|
I think we are practically done with the new logging system. But we have some pendings todo as well:
|
I run ./configure DEBUG=yes
then ./configure --help shows
there is a comment saying that ENABLE_LOG is enabled by default in debug mode, next comes DEFAULT_LOG_SEVERITY, which I didn't specify so it gets default value "error" (SConstruct +349) |
DEBUG = True will enable logging in source code regardless of the ENABLE_LOG flag. For the other problem i've checked in some changes in 0e5dcbd |
I've done a bit of digging and there are still some parts of the mapnik library + plugins that still uses std::cerr and std::clog directly. When we will convert everything to the new logging system i can close the issue. |
great, thanks for helping find the last ones @kunitoki! |
Closing this, as it has been already implemented. It still need some more documentation in the wiki ( https://github.com/mapnik/mapnik/wiki/Runtime-Logging ), otherwise is working very well. |
When developing and debugging (especially on plugins), it should be straight forward to enable / disable debugging printf's per-module: this way i would enable debugging only for the plugin or module under testing, and turn it off for the others.
We should have this kind of priority, something like :
1- Ability to enable or disable GLOBAL debugging print statements in all part of mapnik (everything)
2- Ability to enable or disable PER-GLOBAL-MODULE debugging print statements (core, plugins)
3- Ability to enable or disable PER-MODULE debugging print statements (single logical module)
A higher level control lower levels (if we have a 3rd level enabled but i disable level 2 for the same logical scope, then no debug output)...
Also, to ease runtime control, let decide at runtime if we want to see the debugging or not (via map or session property) ?
The text was updated successfully, but these errors were encountered: