27 #include <boost/date_time.hpp>
35 class null_streambuf :
public std::streambuf
37 virtual int overflow(
int c) {
return std::char_traits< char >::not_eof(c); }
49 static boost::posix_time::time_facet
facet(
"%Y%m%d %H:%M:%S%F ");
119 std::string::size_type
s = name.size();
121 for(
logd &
l : *domains) {
124 }
else if (s > 2 && name.compare(s - 2, 2,
"/*") == 0) {
125 for(
logd &
l : *domains) {
126 if (
l.first.compare(0, s - 1, name, 0, s - 1) == 0)
131 if (it == domains->end())
144 if (it == domains->end())
146 severity = it->second;
152 std::ostringstream
res;
153 for(
logd &
l : *domains) {
154 if(
l.first.find(filter) != std::string::npos)
155 res <<
l.first <<
"\n";
176 tm* lt = localtime(&t);
178 strftime(buf, 100, format.c_str(), lt);
185 const time_t minutes = t / 60;
186 const time_t days = minutes / 60 / 24;
188 strncpy(buf,
"expired", 100);
189 }
else if(minutes == 0) {
190 snprintf(buf, 100,
"00:00:%02ld", t);
191 }
else if(days == 0) {
192 snprintf(buf, 100,
"%02ld:%02ld", minutes / 60, minutes % 60);
194 snprintf(buf, 100,
"%ld %02ld:%02ld", days, (minutes / 60) % 24, minutes % 60);
202 std::ostreambuf_iterator<char>(out),
205 boost::posix_time::microsec_clock::local_time());
213 if (!strict_threw_ && (
severity_ <= strict_level_)) {
214 std::stringstream ss;
215 ss <<
"Error (strict mode, strict_level = " << strict_level_ <<
"): wesnoth reported on channel " <<
name_ <<
" " << domain.
domain_->first;
216 std::cerr << ss.str() << std::endl;
217 strict_threw_ =
true;
232 stream <<
name_ <<
' ' << domain.
domain_->first <<
": ";
242 ticks_ = boost::posix_time::microsec_clock::local_time();
243 (*output_) <<
"{ BEGIN: " <<
str_ <<
"\n";
249 const long ticks = (boost::posix_time::microsec_clock::local_time() -
ticks_).total_milliseconds();
253 (*output_) <<
"} END: " <<
str_ <<
" (took " << ticks <<
"ms)\n";
264 static std::stringstream
lg;
size_t strftime(char *str, size_t count, const std::string &format, const std::tm *time)
static domain_map * domains
static void print_precise_timestamp(std::ostream &out)
std::string get_timestamp(const time_t &t, const std::string &format)
std::ostream & operator()(log_domain const &domain, bool show_names=true, bool do_indent=false) const
~tredirect_output_setter()
static std::ostream * output_stream
std::pair< const std::string, int > logd
bool set_log_domain_severity(std::string const &name, int severity)
static std::ostream & output()
void do_log_entry(log_domain const &domain, const std::string &str)
static bool precise_timestamp
GLenum GLuint GLsizei const char * buf
log_domain(char const *name)
std::ostream * old_stream_
The previously set redirection.
std::map< std::string, int > domain_map
static boost::posix_time::time_facet facet("%Y%m%d %H:%M:%S%F ")
std::stringstream & wml_error()
Use this logger to send errors due to deprecated WML.
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
void set_strict_severity(int severity)
std::string get_timespan(const time_t &t)
bool get_log_domain_severity(std::string const &name, int &severity)
tredirect_output_setter(std::ostream &stream)
Constructor.
GLuint const GLchar * name
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
static bool strict_threw_
std::string list_logdomains(const std::string &filter)
Standard logging facilities (interface).
static std::ostream null_ostream(new null_streambuf)
GLsizei const GLcharARB ** string
void precise_timestamps(bool pt)