ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/slog.C
(Generate patch)

Comparing gvpe/src/slog.C (file contents):
Revision 1.6 by pcg, Thu Aug 7 17:54:27 2008 UTC vs.
Revision 1.7 by root, Tue Feb 8 23:11:36 2011 UTC

41 41
42loglevel log_level = L_INFO; 42loglevel log_level = L_INFO;
43const char *log_identity = ""; 43const char *log_identity = "";
44static int logto = LOGTO_STDERR; 44static int logto = LOGTO_STDERR;
45 45
46loglevel
46loglevel string_to_loglevel (const char *s) 47string_to_loglevel (const char *s)
47{ 48{
48 if (!strcmp (s, "noise")) return L_NOISE; 49 if (!strcmp (s, "noise")) return L_NOISE;
49 if (!strcmp (s, "trace")) return L_TRACE; 50 if (!strcmp (s, "trace")) return L_TRACE;
50 if (!strcmp (s, "debug")) return L_DEBUG; 51 if (!strcmp (s, "debug")) return L_DEBUG;
51 if (!strcmp (s, "info")) return L_INFO; 52 if (!strcmp (s, "info")) return L_INFO;
55 if (!strcmp (s, "critical")) return L_CRIT; 56 if (!strcmp (s, "critical")) return L_CRIT;
56 57
57 return L_NONE; 58 return L_NONE;
58} 59}
59 60
61void
60void log_to (int mask) 62log_to (int mask)
61{ 63{
62 if (logto & LOGTO_SYSLOG) 64 if (logto & LOGTO_SYSLOG)
63 closelog (); 65 closelog ();
64 66
65 logto = mask; 67 logto = mask;
66 68
67 if (logto & LOGTO_SYSLOG) 69 if (logto & LOGTO_SYSLOG)
68 openlog (log_identity, LOG_CONS | LOG_PID, LOG_DAEMON); 70 openlog (log_identity, LOG_CONS | LOG_PID, LOG_DAEMON);
69} 71}
70 72
73void
71void slog_ (const loglevel l, const char *m, ...) 74slog_ (const loglevel l, const char *m, ...)
72{ 75{
73 if (l >= log_level) 76 if (l >= log_level)
74 { 77 {
75 va_list ap; 78 va_list ap;
76 va_start (ap, m); 79 va_start (ap, m);
99 102
100 delete msg; 103 delete msg;
101 } 104 }
102} 105}
103 106
107void
104void fatal (const char *m) 108fatal (const char *m)
105{ 109{
106 slog (L_CRIT, m); 110 slog (L_CRIT, m);
107 exit (EXIT_FAILURE); 111 exit (EXIT_FAILURE);
108} 112}
109 113
114void
110extern void require_failed (const char *file, int line, const char *info) 115require_failed (const char *file, int line, const char *info)
111{ 116{
112 slog (L_CRIT, "FATAL: This program encountered a SHOULD NOT HAPPEN condition and will exit:"); 117 slog (L_CRIT, "FATAL: This program encountered a SHOULD NOT HAPPEN condition and will exit:");
113 slog (L_CRIT, "FATAL+ %s:%d '%s' is false", file, line, info); 118 slog (L_CRIT, "FATAL+ %s:%d '%s' is false", file, line, info);
114 slog (L_CRIT, "FATAL+ This might indicates a bug in this program, a bug in your libraries,"); 119 slog (L_CRIT, "FATAL+ This might indicates a bug in this program, a bug in your libraries,");
115 slog (L_CRIT, "FATAL+ your system setup or operating system. Or it might indicate a very"); 120 slog (L_CRIT, "FATAL+ your system setup or operating system. Or it might indicate a very");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines