summaryrefslogtreecommitdiff
path: root/src/log.h
blob: c41b2c9c40c504a5726512daf58c2511b5fb0e7b (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _LOG_H_
#define _LOG_H_
#include "first.h"

#include "base_decls.h"
#include "buffer.h"

__declspec_dllimport__
extern unix_time64_t log_epoch_secs;
__declspec_dllimport__
extern unix_time64_t log_monotonic_secs;

#if defined(HAVE_CLOCK_GETTIME) && HAS_TIME_BITS64
#define log_clock_gettime(clockid,ts)  clock_gettime((clockid),(ts))
#define log_clock_gettime_realtime(ts) clock_gettime(CLOCK_REALTIME,(ts))
#else
int log_clock_gettime(int clockid, unix_timespec64_t *ts);
int log_clock_gettime_realtime (unix_timespec64_t *ts);
#endif

ssize_t write_all(int fd, const void* buf, size_t count);

__attribute_cold__
__attribute_format__((__printf__, 4, 5))
void log_error(log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...);

__attribute_cold__
__attribute_format__((__printf__, 4, 5))
void log_perror(log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...);

#ifdef _WIN32
__attribute_cold__
__attribute_format__((__printf__, 4, 5))
void log_serror(log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...);
#else
#define log_serror log_perror
#endif

__attribute_cold__
__attribute_format__((__printf__, 6, 7))
void log_error_multiline(log_error_st *errh, const char *filename, unsigned int line, const char * restrict multiline, const size_t len, const char *fmt, ...);

__attribute_cold__
__attribute_returns_nonnull__
log_error_st * log_set_global_errh (log_error_st *errh, int ts_high_precision);

#endif