Liblog
Simple logging library with a unified interface to os_log, syslog, Logcat, and TraceLogging
Install / Use
/learn @holepunchto/LiblogREADME
liblog
Simple logging library with a unified interface to os_log, syslog, Logcat, and TraceLogging.
Usage
#include <log.h>
log_debug("Current pid: %u", getpid());
Consuming logs
macOS
On macOS, Console.app and the log tool can be used to consume logs. To show only messages for a given binary, such as my-app, pass the --predicate flag:
log stream --predicate "process == 'my-app'"
Linux
On Linux, journalctl can be used to consume logs. To show only messages for a given binary, such as my-app, pass the --identifier flag:
journalctl --identifier my-app
Android
On Android, logcat can be used to consume logs. To show only messages for a given binary, such as my-app, pass a filterspec:
adb logcat "*:S my-app:*"
This will silence all logs by default (*:S) and show only those with a name of some-log for all priorities (:*).
Windows
On Windows, the tracelog and traceview tools from the Windows SDK can be used to consume logs. To start a trace on the command line using tracelog for a given binary, such as my-app.exe, do:
tracelog -start my-trace -guid *my-app.exe -f log.etl
When done collecting logs, stop the trace:
tracelog -stop my-trace
To summarize and view the collected logs, use tracefmt:
tracefmt log.etl -o log.txt
API
See include/log.h for the public API.
License
Apache 2.0
