File: log.c

package info (click to toggle)
libdisplay-info 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,460 kB
  • sloc: ansic: 10,055; python: 294; sh: 131; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 840 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "log.h"

void
_di_logger_va_add_failure(struct di_logger *logger, const char fmt[], va_list args)
{
	if (!logger->initialized) {
		if (ftell(logger->f) > 0) {
			fprintf(logger->f, "\n");
		}
		fprintf(logger->f, "%s:\n", logger->section);
		logger->initialized = true;
	}

	fprintf(logger->f, "  ");
	vfprintf(logger->f, fmt, args);
	fprintf(logger->f, "\n");
}

/**
 * Sometimes calling the functions that wrap _di_logger_va_add_failure() (e.g.
 * add_failure() in edid.c) is not possible, because we want to use a specific
 * logger (and not e.g. edid->logger). This allow us to log with a custom
 * logger. Avoid using this if not necessary.
 */
void
_di_logger_add_failure(struct di_logger *logger, const char fmt[], ...)
{
	va_list args;

	va_start(args, fmt);
	_di_logger_va_add_failure(logger, fmt, args);
	va_end(args);
}