Coverage Report

Created: 2026-07-16 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/casync/src/log.h
Line
Count
Source
1
/* SPDX-License-Identifier: LGPL-2.1+ */
2
3
#pragma once
4
5
#include <stddef.h>
6
#include <stdint.h>
7
#include <errno.h>
8
9
#include "gcc-macro.h"
10
11
int log_info_errno(int error, const char* fmt, ...) _printf_(2,3);
12
int log_error_errno(int error, const char* fmt, ...) _printf_(2,3);
13
int log_debug_errno(int error, const char* fmt, ...) _printf_(2,3);
14
15
137
#define log_info(fmt, ...) log_info_errno(0, fmt, ##__VA_ARGS__)
16
0
#define log_error(fmt, ...) log_error_errno(0, fmt, ##__VA_ARGS__)
17
#define log_debug(fmt, ...) log_debug_errno(0, fmt, ##__VA_ARGS__)
18
19
0
static inline int log_oom(void) {
20
0
        log_error("Out of memory");
21
0
        return -ENOMEM;
22
0
}
Unexecuted instantiation: fuzz-compress.c:log_oom
Unexecuted instantiation: compressor.c:log_oom
Unexecuted instantiation: log.c:log_oom
Unexecuted instantiation: util.c:log_oom
23
24
#define assert_se(x)                                                    \
25
0
        do {                                                            \
26
0
                if (!(x)) {                                             \
27
0
                        log_error("%s:%d (%s): assertion failed: %s",   \
28
0
                                  __FILE__, __LINE__, __PRETTY_FUNCTION__, #x); \
29
0
                        abort();                                        \
30
0
                }                                                       \
31
0
        } while(false)
32
33
#define assert_not_reached(x)                                           \
34
0
        do {                                                            \
35
0
                log_error("%s:%d (%s): unreachable code reached: %s",   \
36
0
                          __FILE__, __LINE__, __PRETTY_FUNCTION__, x);  \
37
0
                abort();                                                \
38
0
        } while(false)
39
40
void set_log_level(int level);
41
int set_log_level_from_string(const char *str);