MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsdWriteErrorLog

Function cupsdWriteErrorLog

scheduler/log.c:1245–1304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243 */
1244
1245int /* O - 1 on success, 0 on failure */
1246cupsdWriteErrorLog(int level, /* I - Log level */
1247 const char *message) /* I - Message string */
1248{
1249 int ret = 1; /* Return value */
1250 static const char levels[] = /* Log levels... */
1251 {
1252 ' ',
1253 'X',
1254 'A',
1255 'C',
1256 'E',
1257 'W',
1258 'N',
1259 'I',
1260 'D',
1261 'd'
1262 };
1263
1264
1265#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
1266 if (!strcmp(ErrorLog, "syslog"))
1267 {
1268 sd_journal_print(log_levels[level], "%s", message);
1269 return (1);
1270 }
1271
1272#elif defined(HAVE_VSYSLOG)
1273 /*
1274 * See if we are logging errors via syslog...
1275 */
1276
1277 if (!strcmp(ErrorLog, "syslog"))
1278 {
1279 syslog(log_levels[level], "%s", message);
1280 return (1);
1281 }
1282#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
1283
1284 /*
1285 * Not using syslog; check the log file...
1286 */
1287
1288 if (!cupsdCheckLogFile(&ErrorFile, ErrorLog))
1289 {
1290 ret = 0;
1291 }
1292 else
1293 {
1294 /*
1295 * Write the log message...
1296 */
1297
1298 cupsFilePrintf(ErrorFile, "%c %s %s\n", levels[level],
1299 cupsdGetDateTime(NULL, LogTimeFormat), message);
1300 cupsFileFlush(ErrorFile);
1301 }
1302

Callers 4

cupsdLogClientFunction · 0.85
cupsdLogJobFunction · 0.85
cupsdLogMessageFunction · 0.85
dump_job_historyFunction · 0.85

Calls 4

cupsdCheckLogFileFunction · 0.85
cupsFilePrintfFunction · 0.85
cupsdGetDateTimeFunction · 0.85
cupsFileFlushFunction · 0.85

Tested by

no test coverage detected