-
Notifications
You must be signed in to change notification settings - Fork 825
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
runtime parameter to control datasource plugin strictness and verbosity #986
Comments
We should try to merge efforts here to ease smashing bugs when developing. Other interesting stuff in #937 we should definately consider. |
i've introduced the concept of log severity (much like we have in other logging libraries, especially for java and python). one example:
another example:
this leads to another step: global log class enablers: you can enable or disable severities for all classes independently. we define a macro that takes an identifier #define MAPNIK_DEBUG(s) mapnik::debug(#s)
#define MAPNIK_WARN(s) mapnik::warn(#s)
#define MAPNIK_ERROR(s) mapnik::error(#s) this way you can do things like: static void global_function_example()
{
MAPNIK_DEBUG(global_function_example) << "This will be logged in debug";
}
class test_class
{
public:
test_class()
{
MAPNIK_ERROR(test_class) << "This class will be logged as error";
}
}; then from c++ you can do: using mapnik::logger;
// setting global severity
logger::set_severity(logger::severity::none);
// per object severity overrides
logger::set_object_severity("global_function_example", logger::severity::debug);
logger::set_object_severity("test_class", logger::severity::error); or from python: import mapnik
logger = mapnik.logger
# setting global severity
logger.set_severity(logger.severity.none)
# per object severity overrides
logger.set_object_severity("global_function_example", logger.severity.debug)
logger.set_object_severity("test_class", logger.severity.debug) |
looks powerful. have you also considered allowing setting via an ENV ( |
Where do you think we can place the getenv calls in order to be executed globally ? Calliong getenv everytime we hit a debug print may be too much... |
just was pondering that at startup perhaps the severity default could be set based on ENV value, if it existed. After startup the only way to set it would be through the api. |
where is the mapnik.so startup ? DllMain on windows and attribute((constructor)) init() in linux/solaris ? |
I've started a check for format from getenv when the format itself is first parsed (but the check will be done everytime we output a string), check it at https://github.com/mapnik/mapnik/blob/master/src/debug.cpp#L88 The same for enabling log, or setting global severity. |
okay, no worries - scratch that idea of getenv! |
Well, we could figure out a good way to handle this. What we need to think is how to handle the plugin/library strictness. |
@kunitoki - one issue with the |
yes this seems sensible. it's possible to set the format via API now (and bindings, so probably it's not needed anymore). the only thing could be the output that already do when you import the shared object from python for example, you cannot execute code before it's imported (but this isn't a problem anyway). i will thrash setting the format from CXXFLAGS |
okay, excellent. re: output just from importing the shared object - that will likely be lessened when we move to more lazy datasource creation - this is coming in the |
pretty happy without how this is working now, closing. |
As per #792 - all datasources should (be able) to throw if fields are requested that do not exist in the datasource. The reasoning behind this is that this condition is very hard to debug for stylesheet authors if datasources are silent.
But, we should allow this behavior to be disabled, so that these runtime checks can be bypassed for top speed or in production environments where errors are not desirable.
So, what about all datasources expecting option(s) to control whether error like this throw, print to std::clog, or are silent?
In the CSV plugin I've been using two options like:
Or we could move to something like:
Other ideas for naming?
The text was updated successfully, but these errors were encountered: