android13/external/cpuinfo/deps/clog
liiir1985 7f62dcda9f initial 2024-06-22 20:45:49 +08:00
..
cmake initial 2024-06-22 20:45:49 +08:00
include initial 2024-06-22 20:45:49 +08:00
src initial 2024-06-22 20:45:49 +08:00
test initial 2024-06-22 20:45:49 +08:00
Android.bp initial 2024-06-22 20:45:49 +08:00
CMakeLists.txt initial 2024-06-22 20:45:49 +08:00
LICENSE initial 2024-06-22 20:45:49 +08:00
README.md initial 2024-06-22 20:45:49 +08:00
configure.py initial 2024-06-22 20:45:49 +08:00
confu.yaml initial 2024-06-22 20:45:49 +08:00

README.md

clog: C-style (a-la printf) logging library

BSD (2 clause) License

C-style library for logging errors, warnings, information notes, and debug information.

Features

  • printf-style interface for formatting variadic parameters.
  • Separate functions for logging errors, warnings, information notes, and debug information.
  • Independent logging settings for different modules.
  • Logging to logcat on Android and stderr/stdout on other platforms.
  • Compatible with C99 and C++.
  • Covered with unit tests.

Example

#include <clog.h>

#ifndef MYMODULE_LOG_LEVEL
    #define MYMODULE_LOG_LEVEL CLOG_DEBUG
#endif

CLOG_DEFINE_LOG_DEBUG(mymodule_, "My Module", MYMODULE_LOG_LEVEL);
CLOG_DEFINE_LOG_INFO(mymodule_, "My Module", MYMODULE_LOG_LEVEL);
CLOG_DEFINE_LOG_WARNING(mymodule_, "My Module", MYMODULE_LOG_LEVEL);
CLOG_DEFINE_LOG_ERROR(mymodule_, "My Module", MYMODULE_LOG_LEVEL);

...

void some_function(...) {
    int status = ...
    if (status != 0) {
        mymodule_log_error(
            "something really bad happened: "
            "operation failed with status %d", status);
    }

    uint32_t expected_zero = ...
    if (expected_zero != 0) {
        mymodule_log_warning(
            "something suspicious happened (var = %"PRIu32"), "
            "fall back to generic implementation", expected_zero);
    }

    void* usually_non_null = ...
    if (usually_non_null == NULL) {
        mymodule_log_info(
            "something unusual, but common, happened: "
            "enabling work-around");
    }

    float a = ...
    mymodule_log_debug("computed a = %.7f", a);
}