File: log.h

package info (click to toggle)
linux 6.17.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,734,788 kB
  • sloc: ansic: 26,682,992; asm: 271,227; sh: 147,381; python: 75,980; makefile: 57,306; perl: 36,943; xml: 19,562; cpp: 5,899; yacc: 4,909; lex: 2,943; awk: 1,556; sed: 29; ruby: 25
file content (31 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (32)
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
/* SPDX-License-Identifier: LGPL-2.1+ */
/* Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <daniel.lezcano@linaro.org> */
#ifndef __THERMAL_TOOLS_LOG_H
#define __THERMAL_TOOLS_LOG_H

#include <syslog.h>

#ifndef __maybe_unused
#define __maybe_unused		__attribute__((__unused__))
#endif

#define TO_SYSLOG 0x1
#define TO_STDOUT 0x2
#define TO_STDERR 0x4

extern void logit(int level, const char *format, ...);

#define DEBUG(fmt, ...)		logit(LOG_DEBUG, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__)
#define INFO(fmt, ...)		logit(LOG_INFO, fmt, ##__VA_ARGS__)
#define NOTICE(fmt, ...)	logit(LOG_NOTICE, fmt, ##__VA_ARGS__)
#define WARN(fmt, ...)		logit(LOG_WARNING, fmt, ##__VA_ARGS__)
#define ERROR(fmt, ...)		logit(LOG_ERR, fmt, ##__VA_ARGS__)
#define CRITICAL(fmt, ...)	logit(LOG_CRIT, fmt, ##__VA_ARGS__)
#define ALERT(fmt, ...)		logit(LOG_ALERT, fmt, ##__VA_ARGS__)
#define EMERG(fmt, ...)		logit(LOG_EMERG, fmt, ##__VA_ARGS__)

int log_init(int level, const char *ident, int options);
int log_str2level(const char *lvl);
void log_exit(void);

#endif