Author: mordante
Date: Tue Apr 8 22:44:38 2008
New Revision: 25691
URL: http://svn.gna.org/viewcvs/wesnoth?rev=25691&view=rev
Log:
Added the option to indent the output for the logging, this is handy when using
log_scope/log_scope2.
Modified:
trunk/src/log.cpp
trunk/src/log.hpp
Modified: trunk/src/log.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/log.cpp?rev=25691&r1=25690&r2=25691&view=diff
==============================================================================
--- trunk/src/log.cpp (original)
+++ trunk/src/log.cpp Tue Apr 8 22:44:38 2008
@@ -101,16 +101,22 @@
return buf;
}
-std::ostream &logger::operator()(log_domain const &domain, bool show_names)
const
+std::ostream &logger::operator()(log_domain const &domain, bool show_names,
bool indent) const
{
logd const &d = log_domains[domain.domain_];
if (severity_ > d.severity_)
return null_ostream;
else {
- if (timestamp)
+ if(indent) {
+ for(int i = 0; i != indent; ++i)
+ std::cerr << " ";
+ }
+ if (timestamp) {
std::cerr << get_timestamp(time(NULL));
- if (show_names)
+ }
+ if (show_names) {
std::cerr << name_ << ' ' << d.name_ << ": ";
+ }
return std::cerr;
}
}
Modified: trunk/src/log.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/log.hpp?rev=25691&r1=25690&r2=25691&view=diff
==============================================================================
--- trunk/src/log.hpp (original)
+++ trunk/src/log.hpp Tue Apr 8 22:44:38 2008
@@ -50,7 +50,9 @@
int severity_;
public:
logger(char const *name, int severity): name_(name),
severity_(severity) {}
- std::ostream &operator()(log_domain const &domain, bool show_names =
true) const;
+ std::ostream &operator()(log_domain const &domain,
+ bool show_names = true, bool indent = false) const;
+
bool dont_log(log_domain const &domain) const
{
logd const &d = log_domains[domain.domain_];
@@ -109,4 +111,7 @@
#define LOG_STREAM(a, b) if (lg::a.dont_log(lg::b)) ; else lg::a(lg::b)
+// When using log_scope/log_scope2 it is nice to have all output indented.
+#define LOG_STREAM_INDENT(a,b) if (lg::a.dont_log(lg::b)) ; else lg::a(lg::b,
true, true)
+
#endif
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits