Crinit -- Configurable Rootfs Init
logio.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: MIT
6 #ifndef __LOGIO_H__
7 #define __LOGIO_H__
8 
9 #include <errno.h>
10 #include <stdbool.h>
11 #include <stdio.h>
12 #include <string.h>
13 
17 #define CRINIT_PRINT_PREFIX_MAX_LEN 32
18 
22 #define CRINIT_PRINT_PREFIX "[CRINIT] "
23 
29 #define CRINIT_PRINT_EMPTY_LINE "%s", ""
30 
40 #if __GNUC__ >= 12 || __clang_major__ >= 9
41 #define __FILE_BASENAME__ __FILE_NAME__
42 #else
43 #define __FILE_BASENAME__ (__builtin_strrchr("/" __FILE__, '/') + 1)
44 #endif
45 
51 void crinitSetPrintPrefix(const char *prefix);
63 void crinitSetInfoStream(FILE *stream);
75 void crinitSetErrStream(FILE *stream);
85 void crinitSetUseSyslog(bool sl);
86 
95 void crinitInfoPrint(const char *format, ...) __attribute__((format(printf, 1, 2)));
107 void crinitDbgInfoPrint(const char *format, ...) __attribute__((format(printf, 1, 2)));
108 
112 #define crinitErrPrint(...) crinitErrPrintFFL(__FILE_BASENAME__, __func__, __LINE__, __VA_ARGS__)
126 void crinitErrPrintFFL(const char *file, const char *func, int line, const char *format, ...)
127  __attribute__((format(printf, 4, 5)));
128 
134 #define crinitErrnoPrint(...) crinitErrnoPrintFFL(__FILE_BASENAME__, __func__, __LINE__, __VA_ARGS__)
149 void crinitErrnoPrintFFL(const char *file, const char *func, int line, const char *format, ...)
150  __attribute__((format(printf, 4, 5)));
151 
152 #endif /* __LOGIO_H__ */
static crinitGlobOptStore_t crinitGenericGlobOptHelper __attribute__((unused))
void crinitSetInfoStream(FILE *stream)
Definition: logio.c:49
void crinitSetErrStream(FILE *stream)
Definition: logio.c:55
void crinitSetPrintPrefix(const char *prefix)
Definition: logio.c:43
void crinitErrPrintFFL(const char *file, const char *func, int line, const char *format,...) __attribute__((format(printf
void crinitInfoPrint(const char *format,...) __attribute__((format(printf
void crinitErrnoPrintFFL(const char *file, const char *func, int line, const char *format,...) __attribute__((format(printf
void crinitSetUseSyslog(bool sl)
Definition: logio.c:61
void void crinitDbgInfoPrint(const char *format,...) __attribute__((format(printf