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

Function _cups_debug_set

cups/debug.c:258–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256 */
257
258void
259_cups_debug_set(const char *logfile, /* I - Log file or NULL */
260 const char *level, /* I - Log level or NULL */
261 const char *filter, /* I - Filter string or NULL */
262 int force) /* I - Force initialization */
263{
264 _cupsMutexLock(&debug_init_mutex);
265
266 if (!debug_init || force)
267 {
268 /*
269 * Restore debug settings to defaults...
270 */
271
272 if (_cups_debug_fd != -1)
273 {
274 close(_cups_debug_fd);
275 _cups_debug_fd = -1;
276 }
277
278 if (debug_filter)
279 {
280 regfree((regex_t *)debug_filter);
281 debug_filter = NULL;
282 }
283
284 _cups_debug_level = 1;
285
286 /*
287 * Open logs, set log levels, etc.
288 */
289
290 if (!logfile)
291 _cups_debug_fd = -1;
292 else if (!strcmp(logfile, "-"))
293 _cups_debug_fd = 2;
294 else
295 {
296 char buffer[1024]; /* Filename buffer */
297
298 snprintf(buffer, sizeof(buffer), logfile, getpid());
299
300 if (buffer[0] == '+')
301 _cups_debug_fd = open(buffer + 1, O_WRONLY | O_APPEND | O_CREAT, 0644);
302 else
303 _cups_debug_fd = open(buffer, O_WRONLY | O_TRUNC | O_CREAT, 0644);
304 }
305
306 if (level)
307 _cups_debug_level = atoi(level);
308
309 if (filter)
310 {
311 if ((debug_filter = (regex_t *)calloc(1, sizeof(regex_t))) == NULL)
312 fputs("Unable to allocate memory for CUPS_DEBUG_FILTER - results not "
313 "filtered!\n", stderr);
314 else if (regcomp(debug_filter, filter, REG_EXTENDED))
315 {

Callers 2

_cups_debug_printfFunction · 0.85
_cups_debug_putsFunction · 0.85

Calls 4

_cupsMutexLockFunction · 0.85
regfreeFunction · 0.85
regcompFunction · 0.85
_cupsMutexUnlockFunction · 0.85

Tested by

no test coverage detected