stumpless

a fast and feature-rich logging library for C

https://github.com/goatshriek/stumpless

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 81 committers (1.2%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.2%) to scientific vocabulary

Keywords

c contributions-welcome event-log good-first-issue journald library log logging logging-library sqlite sqlite3 structured-logging syslog
Last synced: 4 months ago · JSON representation ·

Repository

a fast and feature-rich logging library for C

Basic Info
Statistics
  • Stars: 481
  • Watchers: 20
  • Forks: 357
  • Open Issues: 14
  • Releases: 4
Topics
c contributions-welcome event-log good-first-issue journald library log logging logging-library sqlite sqlite3 structured-logging syslog
Created over 11 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security Roadmap

README.md

Stumpless logo

A C logging library built for high performance and a rich feature set.

Linux Builds Windows Builds Mac Builds Coverage Report SonarCloud Status Gitter Apache 2.0 License Contributor Covenant

Français | 한국어 | 简体中文

Key Features | Build and Install | Basic Usage | Contributing

Key Features

Stumpless has lots of features that make logging in C fast and easy: * log to lots of things like Splunk, rsyslog, journald, the Windows Event Log, sqlite, and more! * structured and unstructured logging to suit your needs * builds on Linux, Windows, Mac, FreeBSD, MinGW, MSYS2, Cygwin, DOS, and more! * thread safe * can be adjusted or removed during compilation for zero runtime cost * localized for multiple languages 🇦🇱 🇧🇷 🇧🇬 🇨🇳 🇨🇿 🇩🇪 🇩🇰 🇪🇸 🇫🇷 🇬🇷 🇭🇺 🇮🇳 🇮🇱 🇮🇹 🇯🇵 🇰🇪 🇰🇷 🇵🇱 🇸🇰 🇱🇰 🇸🇪 🇹🇷 🇺🇸 🇪🇬 (add yours!) * easy-access documentation, examples, and support.

What can it log to?

A primary goal of this library is to provide a consistent logging interface to a wide variety of log targets. This means you can focus on defining events and where you want them to go, without finding other SDKs or adding daemons and plugins to get them where you want. Stumpless can write logs to: * Simple character buffers * Files and streams * Unix sockets (such as a local syslog daemon) * Network servers (IPv4 or IPv6, TCP or UDP) * Systemd Journald service * Sqlite3 databases * Windows Event Log * Custom functions, for whatever else you may need!

Don't see what you need? Create an issue with your request and we'll work it into our roadmap!

Quick Build and Install

Stumpless only requires cmake and a cmake-supported build toolchain (like GCC or Visual Studio) to build.

```sh

cloning the latest version of the source tree

git clone git@github.com:goatshriek/stumpless.git

creating a new build directory

mkdir build cd build

configuring the new build

cmake ../stumpless

building stumpless (with 4 threads - adjust as desired)

cmake --build . --parallel 4

install the library (you probably need sudo to do this)

sudo cmake --install . ```

Check out the Installation Instructions for more detail on building and installing stumpless in different environments and/or with other toolchains.

Basic Usage

The simplest way to get started is to use the stumplog function as a direct replacement for the standard library's syslog function:

```c // if you're used to doing this: syslog( LOGINFO | LOGUSER, "My message #%d", count );

// then you can start by changing to this: stumplog( LOGINFO | LOGUSER, "My message #%d", count ); ```

If you haven't opened a target, this will log messages to the default target for the platform: on Linux this is /dev/log, on a Mac system this will be /var/run/syslog, and on a Windows machine it is the Windows Event Log. If you open a target or even a few before calling stumplog, then logs will be sent to the most recently opened target.

If you want an even shorter function call, you can use the stump function to send a message to the current target. You can also use format specifiers just as you would with printf:

c stump( "Login attempt failure #%d for user %s", count, username );

If you don't need format specifiers, use one of the _str variants: it's both faster and safer!

c stump_str( "Login failure! See structured data for info." );

If you want to open a specific target rather than using the default, then just open the one you need and start sending messages. For example, to log to a file named example.log:

```c target = stumplessopenfile_target( "example.log" );

// uses the last opened target by default stump( "Login attempt failure #%d for user %s", count, username ); ```

Sending messages over the network to something like Splunk or rsyslog is just as easy:

c target = stumpless_open_udp4_target( "send-to-splunk-example", "mylogserver.com" ); // or use an IP stump( "Login attempt failure #%d for user %s", count, username );

If you have multiple targets, you can send messages to a chosen target like this:

c stumpless_add_message( target, "Login attempt failure #%d for user %s", count, username );

Severity Shorthand

It's common to specify severity levels directly in logging calls, so stumpless provides some macro functions to make this less verbose and more efficient. For example, to log messages with a severity of INFO, you can do this:

c stump_i( "this gets logged as an info message" );

And if you want to also see source file, line number, and function name info in each message you can use _t (the 't' is for trace):

c stump_t( "this includes source info" );

Using these functions has the added benefit that they can be removed at compile time by simply defining the STUMPLESS_ENABLE_UPTO or STUMPLESS_DISABLE_DOWNTO symbols. This makes it easy to change logging levels between builds, for example to have prod and debug versions without differences in their source code.

```c // be sure to define this before stumpless.h gets included

define STUMPLESSENABLEUPTO_INFO

// ...

// this log will go through just fine stump_i( "I'm doing that thing you asked" );

// this debugging message is completely removed: no runtime impact whatsoever stumpd( "DEBUG info: %d, %d, %s", thing1, thing2, stringythingy ); ```

Check out the headers in stumpless/level to see the full list of severity shorthand functions, or the severity level example to see a complete program in action.

Even more examples

For more detailed examples of the above scenarios, usage of specific target types, how to handle more complicated message structures, and more check out the examples. These include annoted example code files to compile, run, and modify to get you started.

Contributing

Notice a problem or have a feature request? Just create an issue using one of the templates, and we will respond as quickly as we can. You can also look at the project's Contribution Guidelines for more details on the different ways you can give back to the open source community!

If you want to actually write some code or make an update yourself, take a look at the development guide to get a detailed orientation. There are a few options based on your level of experience and familiarity with making contributions.

The first option is to browse the list of issues that are marked with the label good first issue. These issues are selected to be a small but meaningful amount of work, and include details on the general approach that you can take to complete them. They are a great place to start if you are just looking to test the waters of this project or open source contribution in general.

More experienced developers may prefer to look at the full list of issues on the project, as well as the roadmap. If an item catches your interest, drop a comment in the existing issue or open a new one if it doesn't exist yet and state your intent to work on it so that others will have a way to know it is underway.

Documentation and Community

If you're curious about how something in stumpless works that isn't explained here, you can check the appropriate section of the documentation, stored in the docs folder. Folders in the repository contain their own README files that detail what they contain and any other relevant information. The documentation for each function is also hosted on the project website, for both the C library as well as the other language bindings like C++.

Stumpless also includes documentation in local installations in the form of man pages. Once you've installed the library, you can check the documentation for any header file (and the functions it contains) by running man with the name of the header with directories replaced with underscores, for example man stumpless_log.h to see documentation for functions that log simple string messages.

There are also plenty of ways that you can reach out to the project team and broader community for support. * Issues and discussions on Github are good ways to get a response if you have a specific question or suggestion. * There is a persistent chat on gitter where you can find announcements and ask questions. * News about the project are typically announced on Twitter as well by goatshriek, using #StumplessLib. * You can reach the primary maintainer via email if you want private communication. This is the preferred method for notifying us of security issues with the project, so that we can address them as quickly as possible to reduce the risk of abuse.

Owner

  • Name: Joel
  • Login: goatshriek
  • Kind: user

Systems programmer who enjoys learning new technologies.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Stumpless Logging Library
license: Apache-2.0
repository-code: "https://github.com/goatshriek/stumpless"
version: 3.0.0
date-released: 2024-11-28
keywords:
  - journald
  - logging
  - library
  - "structured logging"
  - syslog
  - systemd
  - "windows event log"
type: software
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Joel
    family-names: Anderson
    email: joel@goatshriek.com

GitHub Events

Total
  • Issues event: 27
  • Watch event: 47
  • Delete event: 7
  • Issue comment event: 266
  • Push event: 61
  • Pull request review comment event: 89
  • Pull request review event: 100
  • Pull request event: 87
  • Fork event: 34
  • Create event: 4
Last Year
  • Issues event: 27
  • Watch event: 47
  • Delete event: 7
  • Issue comment event: 266
  • Push event: 61
  • Pull request review comment event: 89
  • Pull request review event: 100
  • Pull request event: 87
  • Fork event: 34
  • Create event: 4

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 296
  • Total Committers: 81
  • Avg Commits per committer: 3.654
  • Development Distribution Score (DDS): 0.378
Past Year
  • Commits: 38
  • Committers: 19
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.763
Top Committers
Name Email Commits
Joel j****3@g****m 184
Shreyank Bhat 7****7 5
Kirubakaran Sujanaranjan 5****e 4
Harry Ramsey h****s@g****m 3
Humac h****c@g****m 3
Mohanakrishnan 6****n 3
m3g4d1v3r 9****r 3
JatishKharade 5****t 3
DevTigerart d****t@g****m 2
Testspieler09 1****9 2
Vasiliy Kiryanov v****v@g****m 2
acass91 a****1@h****m 2
dylmcgold 5****d 2
holyshitcode 1****e 2
igorkole 9****e 2
pedestrianlove 3****e 2
taliezincho t****o 2
Osman 5****r 2
Josh 1****o 2
Jaroslaw-Gawin-Mobica 1****a 2
Gabriel Fioravante g****e@g****m 2
Arnab Bhakta a****v@g****m 2
Anindya a****7@g****m 2
Ewout van Mansom e****t@v****e 1
Fran Tena t****t@g****m 1
Eralp Çelebi e****i@h****m 1
Assaf Bardugo 7****o 1
Tiger 1****y 1
Davide Benini 4****o 1
Daniel w****l@o****m 1
and 51 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 37
  • Total pull requests: 139
  • Average time to close issues: 11 months
  • Average time to close pull requests: 13 days
  • Total issue authors: 6
  • Total pull request authors: 21
  • Average comments per issue: 3.84
  • Average comments per pull request: 2.12
  • Merged pull requests: 118
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 15
  • Pull requests: 58
  • Average time to close issues: 5 months
  • Average time to close pull requests: about 1 month
  • Issue authors: 4
  • Pull request authors: 19
  • Average comments per issue: 3.67
  • Average comments per pull request: 3.4
  • Merged pull requests: 37
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • goatshriek (51)
  • DevTigerart (2)
  • Griezn (1)
  • matthew-macgregor (1)
  • iamsb97 (1)
  • northernSage (1)
  • ritesh006 (1)
  • codehooni (1)
  • aparavind (1)
Pull Request Authors
  • goatshriek (104)
  • iamsb97 (10)
  • ritesh006 (6)
  • DevTigerart (6)
  • holyshitcode (4)
  • vasiliyk (4)
  • Brijeshthummar02 (4)
  • BlinkDynamo (3)
  • m3g4d1v3r (3)
  • codehooni (3)
  • abdalahsalah (2)
  • dylmcgold (2)
  • Griezn (2)
  • Ankaa19 (2)
  • AryasCodeTreks (2)
Top Labels
Issue Labels
help wanted (34) good first issue (33) enhancement (21) hacktoberfest (13) bug (7) refactor (7) testing (6) low code (6) build (4) documentation (4) l10n (4) systemd (1) stale (1)
Pull Request Labels
enhancement (16) refactor (10) l10n (10) documentation (9) stale (7) bug (5) testing (4) build (2) invalid (1) deprecate (1)

Dependencies

Gemfile rubygems
  • wrapture ~> 0.5.0
Gemfile.lock rubygems
  • wrapture 0.5.0
.github/workflows/analysis.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v1 composite
  • github/codeql-action/autobuild v1 composite
  • github/codeql-action/init v1 composite
.github/workflows/cygwin.yml actions
  • actions/cache v2 composite
  • actions/checkout v3 composite
.github/workflows/linux.yml actions
  • actions/checkout v3 composite
  • actions/setup-ruby v1.1.3 composite
  • codecov/codecov-action v3 composite
.github/workflows/locale.yml actions
  • actions/checkout v3 composite
.github/workflows/mac.yml actions
  • actions/checkout v3 composite
  • actions/setup-ruby v1.1.3 composite
  • codecov/codecov-action v3 composite
.github/workflows/windows.yml actions
  • actions/checkout v3 composite
  • actions/setup-ruby v1.1.3 composite