33 const char *appname(WvStringParm log)
const;
34 virtual void log(WvStringParm source,
int loglevel,
35 const char *_buf,
size_t len) = 0;
38 static void cleanup_on_fork(pid_t p);
39 static void static_init();
50 typedef wv::function<
WvString(WvStringParm)> WvLogFilter;
78 static WvLogRcvBaseList *receivers;
79 static int num_receivers, num_logs;
84 WvLog(WvStringParm _app, LogLevel _loglevel = Info,
85 WvLogFilter* filter = 0);
90 virtual bool isok()
const;
101 { loglevel = _loglevel;
return *
this; }
106 LogLevel l = loglevel;
107 size_t x =
lvl(_loglevel).
write(filter ? (*filter)(s) : s);
115 LogLevel l = loglevel;
118 x =
lvl(_loglevel).print((*filter)(
WvString(WVSTRING_FORMAT_CALL)));
120 x =
lvl(_loglevel).print(WVSTRING_FORMAT_CALL);
130 {
return WvStream::operator()(filter ? (*filter)(s) : s); }
133 WvStream::operator()((*filter)(
WvString(WVSTRING_FORMAT_CALL))) :
134 WvStream::operator()(WVSTRING_FORMAT_CALL) );
143 {
return WvLog(app, _loglevel, filter); }
149 virtual size_t uwrite(
const void *buf,
size_t len);
153 { print(
"%s: %s\n", s,
strerror(errno)); }
156 const char *wstype()
const {
return "WvLog"; }
virtual size_t write(const void *buf, size_t count)
Write data to the stream.
static WvString strerror(int errnum)
A replacement for the operating system ::strerror() function that can map more kinds of error strings...
void perror(WvStringParm s)
a useful substitute for the normal C perror() function
virtual bool isok() const
fd==-1, but this stream is always ok
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
WvString is an implementation of a simple and efficient printable-string class.
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
the data structure used by pre_select()/post_select() and internally by select().
WvLog & lvl(LogLevel _loglevel)
change the loglevel.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
WvLog split(LogLevel _loglevel) const
split off a new WvLog object with the requested loglevel.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
virtual size_t uwrite(const void *buf, size_t len)
we override the unbuffered write function, so lines also include the application and log level.
size_t operator()(LogLevel _loglevel, WvStringParm s)
change the loglevel and then print a message.