#include <Logger.h>
Public Types | |
| enum | { Emergency = 0, Alert = 1, Critical = 2, Error = 3, Warning = 4, Notice = 5, Info = 6, Debug = 7 } |
Public Member Functions | |
| Logger (char *fn=NULL, int option=0) | |
| void | open (char *fn) |
| ~Logger () | |
| void | close () |
| Logger & | priority (int p) |
| Logger & | p (int p) |
| Logger & | write (const char *s) |
| Logger & | write (char ch) |
Private Member Functions | |
| int | bufresize (int sz) |
| void | append (const char *s) |
| void | print () |
Private Attributes | |
| std::ofstream | log |
| int | _priority |
| char * | buf |
| int | buflen |
| int | bufsz |
Friends | |
| Logger & | operator<< (Logger &l, const char *s) |
| Logger & | operator<< (Logger &l, const string &s) |
| Logger & | operator<< (Logger &l, char ch) |
| Logger & | operator<< (Logger &l, unsigned int i) |
| Logger & | operator<< (Logger &l, int i) |
Definition at line 33 of file Logger.h.
|
|
Definition at line 74 of file Logger.h.
|
|
||||||||||||
|
Definition at line 103 of file Logger.cc. References _priority, buflen, bufresize(), bufsz, Debug, and open().
|
|
|
Definition at line 116 of file Logger.cc. References close().
00117 {
00118 close();
00119 }
|
|
|
Definition at line 36 of file Logger.cc. References buflen, and bufresize(). Referenced by write().
|
|
|
Definition at line 15 of file Logger.cc. References bufsz. Referenced by append(), and Logger().
00016 {
00017 int nsz;
00018
00019 /* Round up to the next 4k boundary */
00020 nsz = (sz + 0x1000) & ~0xfff;
00021 if (nsz != bufsz) {
00022 /* Add Space */
00023 if (buf)
00024 buf = (char *) realloc(buf, nsz);
00025 else
00026 buf = (char *) malloc(nsz);
00027 if (!buf) {
00028 bufsz = 0;
00029 return 0;
00030 }
00031 bufsz = nsz;
00032 }
00033 return bufsz;
00034 }
|
|
|
Definition at line 129 of file Logger.cc. References log. Referenced by ~Logger().
00130 {
00131 log.close();
00132 }
|
|
|
Definition at line 121 of file Logger.cc. References log. Referenced by Logger(), and main().
|
|
|
|
Definition at line 45 of file Logger.cc. References _priority, buflen, log, and p(). Referenced by CServer::active(), RServer::active(), nnrpd(), nntpd(), ns_article(), ns_stat(), and write().
00046 {
00047 char *nl, *p;
00048
00049 while ((nl = strchr(buf, '\n')) != NULL) {
00050 // Print first line
00051 *nl = '\0';
00052 #ifdef WITH_SYSLOG
00053 syslog(_priority, "%s", buf);
00054 #else
00055 time_t ts;
00056 struct tm *t;
00057 char tbuf[32];
00058 time(&ts);
00059 t = localtime(&ts);
00060 sprintf(tbuf, "%d %04d/%02d/%02d %02d:%02d:%02d ",
00061 _priority, 1900 + t->tm_year, t->tm_mon,
00062 t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
00063 log << tbuf << buf << endl;
00064 #endif
00065
00066 // Move remaining string to the beginning
00067 nl++;
00068 p = buf;
00069 while ((*p++ = *nl++) != '\0');
00070 }
00071 buflen = strlen(buf);
00072 }
|
|
|
Definition at line 135 of file Logger.cc. References _priority, buflen, and write(). Referenced by p().
|
|
|
Definition at line 100 of file Logger.h. References write().
|
|
|
Definition at line 143 of file Logger.cc. References append(), and print(). Referenced by operator<<(), priority(), and write().
|
|
||||||||||||
|
Definition at line 174 of file Logger.cc.
00175 {
00176 char s[256];
00177 sprintf(s, "%d", i);
00178 return l.write(s);
00179 }
|
|
||||||||||||
|
Definition at line 167 of file Logger.cc.
00168 {
00169 char s[256];
00170 sprintf(s, "%u", i);
00171 return l.write(s);
00172 }
|
|
||||||||||||
|
Definition at line 162 of file Logger.cc.
00163 {
00164 return l.write(ch);
00165 }
|
|
||||||||||||
|
Definition at line 156 of file Logger.cc.
00157 {
00158 string s2(s);
00159 return l.write(s2.c_str());
00160 }
|
|
||||||||||||
|
Definition at line 151 of file Logger.cc.
00152 {
00153 return l.write(s);
00154 }
|
|
|
Definition at line 39 of file Logger.h. Referenced by Logger(), print(), and priority(). |
|
|
|
|
|
Definition at line 42 of file Logger.h. Referenced by append(), Logger(), print(), and priority(). |
|
|
Definition at line 42 of file Logger.h. Referenced by bufresize(), and Logger(). |
|
|
|
1.3.6-20040222