wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src log.cpp log.hpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src log.cpp log.hpp
Date: Sat, 26 Mar 2005 11:19:08 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/03/26 16:19:08

Modified files:
        src            : log.cpp log.hpp 

Log message:
        New construct to prevent the game to format and then discard log 
messages: LOG_STREAM(warn, network) will produce a log stream when necessary.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/log.cpp.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/log.hpp.diff?tr1=1.19&tr2=1.20&r1=text&r2=text

Patches:
Index: wesnoth/src/log.cpp
diff -u wesnoth/src/log.cpp:1.20 wesnoth/src/log.cpp:1.21
--- wesnoth/src/log.cpp:1.20    Fri Mar 18 20:51:42 2005
+++ wesnoth/src/log.cpp Sat Mar 26 16:19:08 2005
@@ -1,4 +1,4 @@
-/* $Id: log.cpp,v 1.20 2005/03/18 20:51:42 silene Exp $ */
+/* $Id: log.cpp,v 1.21 2005/03/26 16:19:08 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
                  2004 by Guillaume Melquiond <address@hidden>
@@ -72,7 +72,14 @@
        return true;
 }
 
-std::ostream &logger::operator()(log_domain const &domain, bool show_names)
+
+bool logger::dont_log(log_domain const &domain) const
+{
+       logd const &d = log_domains[domain.domain_];
+       return severity_ > d.severity_;
+}
+
+std::ostream &logger::operator()(log_domain const &domain, bool show_names) 
const
 {
        logd const &d = log_domains[domain.domain_];
        if (severity_ > d.severity_)
@@ -100,7 +107,7 @@
        output_ << "END: " << str_ << " (took " << ticks << "ms)\n";
 }
 
-void scope_logger::do_indent()
+void scope_logger::do_indent() const
 {
        for(int i = 0; i != indent; ++i)
                output_ << "  ";
Index: wesnoth/src/log.hpp
diff -u wesnoth/src/log.hpp:1.19 wesnoth/src/log.hpp:1.20
--- wesnoth/src/log.hpp:1.19    Thu Mar 24 07:41:00 2005
+++ wesnoth/src/log.hpp Sat Mar 26 16:19:08 2005
@@ -1,4 +1,4 @@
-/* $Id: log.hpp,v 1.19 2005/03/24 07:41:00 silene Exp $ */
+/* $Id: log.hpp,v 1.20 2005/03/26 16:19:08 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
                  2004 by Guillaume Melquiond <address@hidden>
@@ -35,7 +35,8 @@
        int severity_;
 public:
        logger(char const *name, int severity): name_(name), 
severity_(severity) {}
-       std::ostream &operator()(log_domain const &domain, bool show_names = 
true);
+       std::ostream &operator()(log_domain const &domain, bool show_names = 
true) const;
+       bool dont_log(log_domain const &domain) const;
 };
 
 extern logger err, warn, info;
@@ -49,7 +50,7 @@
 public:
        scope_logger(log_domain const &domain, std::string const &str);
        ~scope_logger();
-       void do_indent();
+       void do_indent() const;
 };
 
 } // namespace lg
@@ -57,4 +58,6 @@
 #define log_scope(a) lg::scope_logger scope_logging_object__(lg::general, a);
 #define log_scope2(a,b) lg::scope_logger scope_logging_object__(lg::a, b);
 
+#define LOG_HELPER(a, b) if (lg::a.dont_log(lg::b)) ; else lg::a(lg::b)
+
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]