Skip to content

Simple logging library with a unified interface to os_log, syslog, Logcat, and TraceLogging

License

Notifications You must be signed in to change notification settings

holepunchto/liblog

Repository files navigation

liblog

Simple logging library with a unified interface to os_log, syslog, Logcat, and TraceLogging.

Usage

#include <log.h>

log_open("some-log", 0); 

log_debug("Current pid: %u", getpid());

log_close();

Consuming logs

macOS

On macOS, Console.app and the log tool can be used to consume logs. To show only message for a given log, such as some-log in the previous example, pass the --predicate flag:

log stream --predicate "subsystem == '<name>'"

Linux

On Linux, journalctl can be used to consume logs. To show only messages for a given log, such as some-log in the previous example, pass the --identifier flag:

journalctl --identifier <name>

Android

On Android, logcat can be used to consume logs. To show only messages for a given log, such as some-log in the previous example, pass a filterspec:

adb logcat "*:S some-log:*"

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 log, such as some-log in the previous example, do:

tracelog -start my-trace -guid *some-log -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

About

Simple logging library with a unified interface to os_log, syslog, Logcat, and TraceLogging

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •