{"id":13810748,"url":"https://github.com/kevincox/sog","last_synced_at":"2026-03-14T02:56:42.403Z","repository":{"id":141756596,"uuid":"88204570","full_name":"kevincox/sog","owner":"kevincox","description":"Efficent c++ structured logging library.","archived":false,"fork":false,"pushed_at":"2017-06-26T20:54:32.000Z","size":66,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-12T04:42:09.684Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevincox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-13T20:39:40.000Z","updated_at":"2023-10-28T14:19:52.000Z","dependencies_parsed_at":"2024-01-15T13:39:57.534Z","dependency_job_id":"93adc048-b3bf-4e09-aafe-2c4a2da0f0f8","html_url":"https://github.com/kevincox/sog","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincox%2Fsog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincox%2Fsog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincox%2Fsog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincox%2Fsog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevincox","download_url":"https://codeload.github.com/kevincox/sog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254171728,"owners_count":22026500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T03:00:24.752Z","updated_at":"2026-03-14T02:56:42.370Z","avatar_url":"https://github.com/kevincox.png","language":"C++","funding_links":[],"categories":["Projects built with Bazel"],"sub_categories":["non-Google projects"],"readme":"# Sog\n\nWarning: sog is still a work in progress, but the basics work.\n\nSog is an ad-hoc structured logging library for c++. It focuses on ease of use and performance.\n\n```c++\nLOG(INFO, \"I'm writing a $type log message with $lib!\",\n\ttype, \"structured\",\n\tlib, \"sog\");\n```\n\n## Goals\n\n### Ad-hoc\n\nAd-hoc means that there is no predefined structure. Sog isn't aimed at logging events of a specific schema. While it can be used for this in many cases it lacks features such as multiple streams that make it non-idea.\n\n### Efficient\n\nUsing c++ features sog manages to make logging very cheep. As much as possible is put into a once-per message setup, allowing subsequent messages to do only the following.\n\n- Check source has been initialized. (c++ local static check)\n- TODO: Check if source is enabled. (currently all sources are enabled).\n- Prepare message values.\n- Virtual function call to sink.\n\nThis requires no allocations once prepared. This overhead is likely far less then any useful source (and often cheaper then computing the values to log).\n\n### Flexible\n\nSog uses pluggable sinks. This means that your program can choose what to do with it's log messages. It's easy to [write your own](sog/sink.h) and sog comes with the following sinks created for you.\n- PrettySink: This sink it intended for human output, it evaluates the template with the provided values and logs the message to the terminal (or any provided std::ostream).\n- JsonSink: This logs one JSON object on it's own line for each message.\n- JournaldSink: This logs to [journald](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html).\n- TODO: FanSink: This sink sends messages to any number of other sinks. Useful for logging full messages (example JSON) while still outputting to the terminal for developers.\n- TODO: BufferSink: This sink buffers messages temporarily in memory before forwarding to another sink.\n\n## Getting Started\n\n### Initialize Sog\n\nInitialize sog at the start of main. It is an error to initialize sog twice or to log a message before sog is initialized.\n\n```c++\n#include \u003csog/init.h\u003e\n\nsog::init();\n```\n\nBy default sog uses the PrettySink to stderr. You can pass a sink to `init()` to use a different one.\n\n```c++\n#include \u003csog/init.h\u003e\n#include \u003csog/json.h\u003e // Coming soon.\n\nsog::JsonSink sink;\nsog::init(\u0026sink);\n```\n\n### Log Away\n\nSog provides a macro to make logging easy. It takes care of stringifying keys as well as making sure the [source](docs/glossary.md#source) is prepared the first time this log is hit.\n\n```\nLOG(level, human_message, [key, value]...);\n```\n\n```c++\n#include \u003csog/macro.h\u003e\n\nauto host = \"example.com\";\nnet::ip addr = \"2001:db8::99\";\nLOG(INFO, \"Connecting to $host ($ip)\",\n\thost, host,\n\tip, addr,\n\tretries, 3);\n```\n\n## Documentation\n\nGeneral documentation is available in [the docs subdirectory](docs/) and c++ interface documentation is available in the headers. Some useful files are:\n- [sog/init.h](sog/init.h) contains useful information for initializing sog.\n- [sog/macro.h](sog/macro.h) contains the LOG macro.\n- [sog/sink.h](sog/sink.h) describes how to write your own sink.\n- [sog/base.h](sog/base.h) contains the base data types.\n\n## Build\n\nSog depends on the following libraries.\n- boost: Build dependency for sog and any libraries using sog.\n- googletest: Test dependency for sog.\n\nSog can be build with [bazel](https://bazel.build).\n\n```sh\n$ bazel build -c opt :sog\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevincox%2Fsog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevincox%2Fsog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevincox%2Fsog/lists"}