ivan.cuevas Posted February 13, 2012 Share Posted February 13, 2012 Hi, One interesting feature (and I think not so hard to develop) is to include a minimum log message level. It can be defined at unigine.cfg file as follows: <item name="log_level" type="string">"warning"</item> All the messages under this level mustn't be included in log.html file. With this feature and the inclusion of "debug" log level (log.debug) you can keep messages in critical parts of your code and easily activate/deactivate them. Currently I'm using #define macros to achieve this, but it's not the best solution. log4cxx uses this feature, but in our case, it's much more simple. Cheers, Iván. 1 Link to comment
ulf.schroeter Posted February 13, 2012 Share Posted February 13, 2012 For sure easy to implement but you would get message formatting / invocation penalty for all blocked log levels during runtime which is bad for release builds Link to comment
ivan.cuevas Posted February 13, 2012 Author Share Posted February 13, 2012 The cost is compare two integers for each log call. The benefits are: Quickly restore messages to fix bugs or benchmark code. Save time spent formating and writting undesired messages (some of them lost in code) In my opinion it's a low penalty. Another idea is to have log level comparision in debug builds (as breakpoint function) using macros. //for each log function /* */ void Log::message(string msg) { #ifdef DEBUG if(MESSAGE_LEVEL < current_log_level) return; #endif /* DEBUG */ // ... } Link to comment
ulf.schroeter Posted February 14, 2012 Share Posted February 14, 2012 I don't think the integer compare would be an issue. Can remember some profiling where the actual message text formatting took 10x the time required for log message invocation itself. I would doubt that unigine script compiler can optimize this dead code away when not needed due to log level setting. Link to comment
manguste Posted March 1, 2012 Share Posted March 1, 2012 There are already warnings, errors and messages, so if you need to implement a minimum message level, why not write custom wrapper functions in script? Link to comment
Recommended Posts