Name Date Size #Lines LOC

..--

cmake/H25-Apr-2025-1613

include/H25-Apr-2025-10188

src/H25-Apr-2025-437350

test/H25-Apr-2025-4737

.gitignoreH A D25-Apr-2025180 2017

Android.bpH A D25-Apr-20251.2 KiB4844

BUILD.bazelH A D25-Apr-20251.3 KiB5950

CMakeLists.txtH A D25-Apr-20253.4 KiB9885

LICENSEH A D25-Apr-20251.4 KiB2721

README.mdH A D25-Apr-20251.7 KiB5844

configure.pyH A D25-Apr-2025670 2716

confu.yamlH A D25-Apr-2025107 65

README.md

1# clog: C-style (a-la printf) logging library
2
3[![BSD (2 clause) License](https://img.shields.io/badge/License-BSD%202--Clause%20%22Simplified%22%20License-blue.svg)](https://github.com/pytorch/cpuinfo/blob/master/deps/clog/LICENSE)
4
5C-style library for logging errors, warnings, information notes, and debug information.
6
7## Features
8
9- printf-style interface for formatting variadic parameters.
10- Separate functions for logging errors, warnings, information notes, and debug information.
11- Independent logging settings for different modules.
12- Logging to logcat on Android and stderr/stdout on other platforms.
13- Compatible with C99 and C++.
14- Covered with unit tests.
15
16## Example
17
18```c
19#include <clog.h>
20
21#ifndef MYMODULE_LOG_LEVEL
22    #define MYMODULE_LOG_LEVEL CLOG_DEBUG
23#endif
24
25CLOG_DEFINE_LOG_DEBUG(mymodule_, "My Module", MYMODULE_LOG_LEVEL);
26CLOG_DEFINE_LOG_INFO(mymodule_, "My Module", MYMODULE_LOG_LEVEL);
27CLOG_DEFINE_LOG_WARNING(mymodule_, "My Module", MYMODULE_LOG_LEVEL);
28CLOG_DEFINE_LOG_ERROR(mymodule_, "My Module", MYMODULE_LOG_LEVEL);
29
30...
31
32void some_function(...) {
33    int status = ...
34    if (status != 0) {
35        mymodule_log_error(
36            "something really bad happened: "
37            "operation failed with status %d", status);
38    }
39
40    uint32_t expected_zero = ...
41    if (expected_zero != 0) {
42        mymodule_log_warning(
43            "something suspicious happened (var = %"PRIu32"), "
44            "fall back to generic implementation", expected_zero);
45    }
46
47    void* usually_non_null = ...
48    if (usually_non_null == NULL) {
49        mymodule_log_info(
50            "something unusual, but common, happened: "
51            "enabling work-around");
52    }
53
54    float a = ...
55    mymodule_log_debug("computed a = %.7f", a);
56}
57```
58