3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 Use this for logging everything.
28 If you need to explicitly print something, use dstream or cout or cerr.
31 enum LogMessageLevel {
32 LMT_ERROR, /* Something failed ("invalid map data on disk, block (2,2,1)") */
33 LMT_ACTION, /* In-game actions ("celeron55 placed block at (12,4,-5)") */
34 LMT_INFO, /* More deep info ("saving map on disk (only_modified=true)") */
35 LMT_VERBOSE, /* Flood-style ("loaded block (2,2,2) from disk") */
42 /* line: Full line with timestamp, level and thread */
43 virtual void printLog(const std::string &line){};
44 /* line: Full line with timestamp, level and thread */
45 virtual void printLog(const std::string &line, enum LogMessageLevel lev){};
46 /* line: Only actual printed text */
47 virtual void printLog(enum LogMessageLevel lev, const std::string &line){};
50 void log_add_output(ILogOutput *out, enum LogMessageLevel lev);
51 void log_add_output_maxlev(ILogOutput *out, enum LogMessageLevel lev);
52 void log_add_output_all_levs(ILogOutput *out);
53 void log_remove_output(ILogOutput *out);
55 void log_register_thread(const std::string &name);
56 void log_deregister_thread();
58 void log_printline(enum LogMessageLevel lev, const std::string &text);
60 #define LOGLINEF(lev, ...)\
63 snprintf(buf, 10000, __VA_ARGS__);\
64 log_printline(lev, buf);\
67 extern std::ostream errorstream;
68 extern std::ostream actionstream;
69 extern std::ostream infostream;
70 extern std::ostream verbosestream;
72 extern bool log_trace_level_enabled;
74 #define TRACESTREAM(x){ if(log_trace_level_enabled) verbosestream x; }
75 #define TRACEDO(x){ if(log_trace_level_enabled){ x ;} }