clibs
Tiny but handy utility libraries for C
Loading...
Searching...
No Matches
print.h
Go to the documentation of this file.
1
12
13#ifndef CLIBS_PRINT_H
14#define CLIBS_PRINT_H
15
16#include <stdio.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
28void clibs_set_output(FILE *out, FILE *err);
29
33FILE *clibs_get_out(void);
34
38FILE *clibs_get_err(void);
39
44#define PRINT(fmt, ...) \
45 do { fprintf(clibs_get_out(), fmt, ##__VA_ARGS__); } while (0)
46
51#define PERROR(fmt, ...) \
52 do { fprintf(clibs_get_err(), fmt, ##__VA_ARGS__); } while (0)
53
58#define PUTS(fmt, ...) \
59 do { fprintf(clibs_get_out(), fmt "\n", ##__VA_ARGS__); } while (0)
60
65#define PUTERR(fmt, ...) \
66 do { fprintf(clibs_get_err(), fmt "\n", ##__VA_ARGS__); } while (0)
67
72#define DEBUG_INFO(fmt, ...) \
73 do { fprintf(clibs_get_err(), "(%s:%d) " fmt "\n", \
74 __FILE__, __LINE__, ##__VA_ARGS__); } while (0)
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif /* CLIBS_PRINT_H */
FILE * clibs_get_out(void)
Gets current output stream (fallback: stdout).
Definition clibs_logging.c:31
void clibs_set_output(FILE *out, FILE *err)
Sets thread-local output and error streams.
Definition clibs_logging.c:26
FILE * clibs_get_err(void)
Gets current error stream (fallback: stderr).
Definition clibs_logging.c:35