[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src log.cpp log.hpp campaign_server/cam...
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src log.cpp log.hpp campaign_server/cam... |
Date: |
Sun, 01 May 2005 04:57:54 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/05/01 08:57:54
Modified files:
src : log.cpp log.hpp
src/campaign_server: campaign_server.cpp
Log message:
A try at timestamping log messages (in the campaign server for now).
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/log.cpp.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/log.hpp.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/campaign_server/campaign_server.cpp.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
Patches:
Index: wesnoth/src/campaign_server/campaign_server.cpp
diff -u wesnoth/src/campaign_server/campaign_server.cpp:1.15
wesnoth/src/campaign_server/campaign_server.cpp:1.16
--- wesnoth/src/campaign_server/campaign_server.cpp:1.15 Mon Apr 4
15:56:07 2005
+++ wesnoth/src/campaign_server/campaign_server.cpp Sun May 1 08:57:54 2005
@@ -1,5 +1,6 @@
#include "config.hpp"
#include "filesystem.hpp"
+#include "log.hpp"
#include "network.hpp"
#include "publish_campaign.hpp"
#include "util.hpp"
@@ -10,6 +11,8 @@
#include <iostream>
+#define LOG_CS lg::err(lg::network, false)
+
namespace {
config construct_message(const std::string& msg)
@@ -71,7 +74,7 @@
network::connection sock = network::accept_connection();
if(sock) {
- std::cerr << "received connection from " <<
network::ip_address(sock) << "\n";
+ LOG_CS << "received connection from " <<
network::ip_address(sock) << "\n";
}
config data;
@@ -166,13 +169,13 @@
}
} catch(network::error& e) {
if(!e.socket) {
- std::cerr << "fatal network error\n";
+ LOG_CS << "fatal network error\n";
break;
} else {
e.disconnect();
}
} catch(config::error& e) {
- std::cerr << "error in receiving data...\n";
+ LOG_CS << "error in receiving data...\n";
}
SDL_Delay(500);
@@ -183,6 +186,7 @@
int main(int argc, char** argv)
{
+ lg::timestamps(true);
try {
campaign_server("server.cfg").run();
} catch(config::error& e) {
Index: wesnoth/src/log.cpp
diff -u wesnoth/src/log.cpp:1.22 wesnoth/src/log.cpp:1.23
--- wesnoth/src/log.cpp:1.22 Sat Mar 26 16:22:24 2005
+++ wesnoth/src/log.cpp Sun May 1 08:57:54 2005
@@ -1,4 +1,4 @@
-/* $Id: log.cpp,v 1.22 2005/03/26 16:22:24 silene Exp $ */
+/* $Id: log.cpp,v 1.23 2005/05/01 08:57:54 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
2004 by Guillaume Melquiond <address@hidden>
@@ -19,6 +19,7 @@
#include "log.hpp"
#include <algorithm>
+#include <ctime>
#include <iostream>
#include <sstream>
#include <vector>
@@ -42,9 +43,12 @@
static std::vector< logd > log_domains;
static std::ostream null_ostream(new null_streambuf);
static int indent = 0;
+static bool timestamp = false;
namespace lg {
+void timestamps(bool t) { timestamp = t; }
+
logger err("error", 0), warn("warning", 1), info("info", 2);
log_domain general("general"), ai("ai"), config("config"), display("display"),
engine("engine"),
network("network"), filesystem("filesystem");
@@ -86,8 +90,12 @@
if (severity_ > d.severity_)
return null_ostream;
else {
+ if (timestamp) {
+ time_t t = time(NULL);
+ std::cerr << ctime(&t) << ' ';
+ }
if (show_names)
- std::cerr << name_ << " " << d.name_ << ": ";
+ std::cerr << name_ << ' ' << d.name_ << ": ";
return std::cerr;
}
}
Index: wesnoth/src/log.hpp
diff -u wesnoth/src/log.hpp:1.22 wesnoth/src/log.hpp:1.23
--- wesnoth/src/log.hpp:1.22 Sat Mar 26 16:22:24 2005
+++ wesnoth/src/log.hpp Sun May 1 08:57:54 2005
@@ -1,4 +1,4 @@
-/* $Id: log.hpp,v 1.22 2005/03/26 16:22:24 silene Exp $ */
+/* $Id: log.hpp,v 1.23 2005/05/01 08:57:54 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
2004 by Guillaume Melquiond <address@hidden>
@@ -39,6 +39,8 @@
bool dont_log(log_domain const &domain) const;
};
+void timestamps(bool);
+
extern logger err, warn, info;
extern log_domain general, ai, config, display, engine, network, filesystem;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src log.cpp log.hpp campaign_server/cam...,
Guillaume Melquiond <=