From 2b9c8881877dcb1835f17a0c5b642784c738049f Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Sun, 4 Jul 1999 12:00:07 +0000 Subject: Initial import. --- lib/log.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/log.cc (limited to 'lib/log.cc') diff --git a/lib/log.cc b/lib/log.cc new file mode 100644 index 0000000..7932e84 --- /dev/null +++ b/lib/log.cc @@ -0,0 +1,25 @@ +//#include +//#include + +#include "log.h" + +logbuf::logbuf(int _level) { + ptr = buf; + len = 0; + level = _level; +} + +int logbuf::overflow(int c) { + if (c == '\n') { + *ptr++ = '\n'; + *ptr = '\0'; + syslog(level, buf); + ptr = buf; + return 0; + } + if ((len + 2) >= sizeof(buf)) + return EOF; + *ptr++ = c; + len++; + return 0; +} -- cgit v1.2.3