Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

The Standard Incident Reporter library: A lightweight, cross-platform library for information distribution.

License

NotificationsYou must be signed in to change notification settings

aremmell/libsir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libsir—a lightweight, cross-platform library for information distribution

ReleaseCommitsLicenseOpenHubGitLabCoverageCoverityREUSEMaintainabilityReliabilitySecurityScorecardPractices

libsir is a cross-platform, thread-safe logging library written in C (ISO/IEC 9899:2011 C11) that is designed to simplify and streamline the generation and distribution of human-readable information in software.

Using libsir, you can make a single call that simultaneously sends information to multiple destinations,each with their own individual preference for format and levels.

Each 'level' or 'priority' of output can be visually styled however you wish forstdio destinations. This allows for immediate visual confirmation that a message appeared in the terminal that you should pay attention to, while less pressing information is more subtle in appearance.

libsir visual graph

  • No dependencies (other thanlibc andpthreads). On Windows, libsir uses the native synchronization API.
  • Accompanied by a robust test suite to ensure dependable behavior, even if you make modifications to the source.
  • Won't fail silently—C library or platform level errors are captured and stored for posterity, on a per-thread basis. Thefunction, file, and line number from which it originated are also captured. Additionally, libsir defines its own set of error messages to aid in troubleshooting.
  • Hardened—every function contains sanity checks for internal state as well as arguments passed in through the external interfaces. libsir's standard make recipes use‑Wall ‑Wextra ‑Wpedantic (and pass with‑Wmissing‑prototypes ‑Wdouble‑promotion ‑Wfloat‑conversion ‑Wmissing‑declarations ‑Wswitch‑enum ‑Wformat‑nonliteral ‑Wformat‑truncation ‑Wbad‑function‑cast ‑Wextra‑semi‑stmt, too.)
  • Full documentation, thanks to Doxygen.
  • Lightweight—the shared library comes in at around 70 KiB, and the static library around 50 KiB.

At this time, libsir is supported (that is, it compiles and passes the test suites) on at least the following operating system and toolchain combinations:

SystemToolchain
Linux ≳2.6.32
(glibc ≳2.4, musl ≳1.2.3, uClibc‑ng ≳1.0.43)
GCC (4.4.7 ‑ 14.2.1), Clang (3.8 ‑ 19.1.7), Oracle Studio C/C++ (≳12.6), Circle (1.0.0‑210 ‑ 1.0.0‑226), IBM Advance Toolchain (14 ‑ 17), IBM XL C/C++ (16.1.1.2 ‑ 16.1.1.15), IBM Open XL C/C++ (17.1.1.0 ‑ 17.1.1.2), NVIDIA HPC SDK C/C++ (23.5 ‑ 25.1), Arm HPC C/C++ (22.1 ‑ 24.10.1), DMD ImportC (2.104.2 ‑ 2.110.0), AMD Optimizing C/C++ (4.0.0 ‑ 5.0.0), Intel oneAPI DPC++/C++ (2023.1 ‑ 2025.0.4), Open64 (5, AMD 4.5.2.1), Intel C++ Compiler Classic (2021.9.0 ‑ 2021.10.0), Portable C Compiler (1.2.0.DEVEL‑20230730), Kefir (≳0.3.0), Chibicc (2020.12.6), CompCert C (3.11 ‑ 3.15, no‑TLS), Chamois‑CompCert C (3.14‑20231130+, TLS), МЦСТ LCC (1.25 ‑ 1.29)
Android ≳5Android NDK (r25c ‑ r27c)
QNX 8.0QCC (GCC 12.2)
IBM AIX 7.2, 7.3GCC (8.3 ‑ 12.3), Clang (18.1.2 ‑ 19.1.7), IBM XL C/C++ (16.1.0.3 ‑ 16.1.0.20), IBM Open XL C/C++ (17.1.1.1 ‑ 17.1.3.0)
IBM i (PASE) 7.5GCC (10.3.0 ‑ 10.5.0), IBM XL C/C++ (16.1.0.15 ‑ 16.1.0.20)
macOS ≳10.15Xcode (11.7 ‑ 16.2), GCC (10.4 ‑ 14.2.0), Clang (11.0.3 ‑ 19.1.7), DMD ImportC (2.105.0 ‑ 2.110.0), Intel C++ Compiler Classic (2021.9.0 ‑ 2021.10.0)
Windows ≳10, 11Microsoft Visual C/C++ (17.6 ‑ 17.13.1), Clang‑CL (16.0.6 ‑ 19.1.7), GCC‑MinGW (12.2.1 ‑ 14.2.1), LLVM‑MinGW (15.0 ‑ 19.1.7), Embarcadero C++ (7.20 ‑ 7.70), OrangeC (≳6.71.10)
Cygwin 3.4GCC (11.2 ‑ 13.2.1)
FreeBSD ≳11.3GCC (11.4 ‑ 13.2.1), Clang (10 ‑ 19.1.7), DMD ImportC (2.105.0 ‑ 2.110.0)
NetBSD 9.2, 10GCC (7.5 ‑ 14.2), Clang (15.0.7 ‑ 18.1.8)
OpenBSD 7.3GCC (11.2), Clang (13 ‑ 18.1.8), DMD ImportC (2.106.0 ‑ 2.110.0)
DragonFly BSD 6.4GCC (8.3 ‑ 13), Clang (10.0.1 ‑ 17.0.6)
GNU/HurdGCC (9.5 ‑ 13.2), Clang (9.0.1 ‑ 13.0.1)
Haiku R1b4GCC (11.2 ‑ 13.2), Clang (12.0.1 ‑ 18.1.7)
Solaris 11.4GCC (10.3 ‑ 11.2), Clang (6 ‑ 18.1.8), Oracle Studio C/C++ (≳12.6)
illumosGCC (7.5 ‑ 13.2), Clang (15.0.7 ‑ 18.1.8), Oracle Studio C/C++ (≳12.6)
SerenityOSGCC (13.1)
WebAssembly/JSEmscripten (3.1.45 ‑ 4.0.1), Node.js (20.5.0 ‑ 23.7.0)
  • libsir is known to work on most common (and many uncommon) architectures. It has been built and tested onIntel (x86_64, i686, x32),ARM (ARMv6, ARMv7HF, ARMv8‑A),POWER (PowerPC, PPC64, PPC64le),MIPS (MIPS64, MIPS32, 74Kc),SPARC (SPARC64, V8, LEON3),z/Architecture (S390X),SuperH (SH‑4A),RISC‑V (RV32, RV64),OpenRISC (OR1200),Kalray MPPA® (Coolidge™, KVX),МЦСТ Эльбрус (E2K), andm68k (ColdFire, 68020+).
  • This table only lists toolchains that have been tested and is by no means exhaustive—newer (or older) versions are likely to work without fanfare. In fact, if itdoesn't work on your machine, it's probably a bug.

libsir currently supports the following system logging facilities:

Log FacilitySystemDescription
Event LogWindowsSystem log viewable withEvent Viewer
os_logmacOSSystem log viewable withConsole (orlog)
syslog(many)BSD-style system logging viasyslog() (local only)
  • Bindings for scripting tools and other high-level programming languages are available, including support for:

     Ch  Python 

Some sample terminal output from libsir demonstrating the default text styling settings for stdio (note that this is just a sample; libsir supports 4, 8, and 24-bit color modes, so a virtually limitless number of configurations are possible):

sample terminal output

This output is from theexample application, whose source code can be located in theexample directory. If you're curious about a very basic implementation of libsir in a practical context, that's a good place to start.

Coming soon: A C++20 version of the example program.

There are several options available for building libsir from source:

The Makefiles are compatible withGNU Make version3.81 and later (4.4recommended) and support both native and cross-compilation builds on most Unix-like operating systems: AIX, Solaris, illumos, Linux, macOS, Cygwin, BSD, GNU/Hurd, Haiku, QNX, etc.

A number of environment variables are available which affect the way in which libsir and its various build artifacts are created (e.g., turning off optimizations and enabling debug symbols). Information about these variables and how to use them with GNU make can be found in theonline documentation.

Recipe TypeCommand    Output file(s)
Test suite (C)make tests
  • build/bin/sirtests[.exe]
Test suite (C++)make tests++
  • build/bin/sirtests++[.exe]
Example appmake example
  • build/bin/sirexample[.exe]
Static librarymake static
  • build/lib/libsir_s.a
nShared librarymake shared
  • build/lib/libsir.so
Installationmake install
  • $PREFIX/lib/libsir_s.a
  • $PREFIX/lib/libsir.so
  • $PREFIX/include/sir.h
  • $PREFIX/include/sir/*.h

A VS Code workspace file is located in the root of the repository (sir.code-workspace). Build tasks are only configured for macOS and Linux. On other platforms, use the integrated terminal to run GNUmake manually.

To run a task, open the command list ( + +P on macOS, + +P on Linux), then start typing"run task" until you see"Tasks: Run Task". Click the item or press the key combination listed next to it. You should then see a drop-down menu containing all of the build tasks for libsir, which are listed here:

Build TaskDescription
CleanDeletes all intermediate files and previously compiled binaries.
Static LibraryCompiles libsir as a static library.
Static Library [DBG]Compiles libsir as a static library with debug symbols.
Shared LibraryCompiles libsir as a shared library.
Shared Library [DBG]Compiles libsir as a shared library with debug symbols.
C Test SuiteCompiles the C test suite.
C Test Suite [DBG]Compiles the C test suite with debug symbols.
C++ Test SuiteCompiles the C++ test suite.
C++ Test Suite [DBG]Compiles the C++ test suite with debug symbols.
C Example AppCompiles the C sample application.

The VS Code build tasks executemake under the hood—the non-debug tasks map directly to therecipes listed under Unix Makefile; the debug tasks utilize libsir's customenvironment variables to control the build process.

A Visual Studio 2022 solution containing appropriate project files can be found in themsvs directory. Tested on Windows 11 (x86, x64, and Arm64) with Visual Studio 17.6+. See theREADME for more information.

Visual Studio is technically not required in order to build the Visual Studio 2022 solution; this may also be accomplished using "Build Tools for Visual Studio 2022" (download,reference). This is a stand-alone toolchain that doesnot require Visual Studio 2022 and includes compilers and MSBuild.

Using MSBuild from the command-line

Using MSBuild is pretty straightforward. Start a Developer Command Prompt, and then just supply the path to the.sln file, task (e.g.build), configuration (e.g.release), and platform (e.g.x64). Here's an example that builds libsir in release mode for x86_64 when executed from the root of the libsir repository:

MSBuild.\msvs\libsir.sln-t:Rebuild-p:Configuration=Release-p:Platform=x64

If you are genuinely interested in utilizing libsir, you are encouraged to read thefull online documentation to get a better understanding of the library's capabilities and interfaces.

Suggested initial sections:

The developers are obsessed with the quality, reliability, and correctness of libsir.

The followingSAST (static application/analysis security/software testing) and dynamic verification tools are used—onevery commit—as part of our comprehensivecontinuous integration testing process:

ToolUsage
PVS-StudioStatic analysis tool for C, C++, C#, and Java code
Clang Analyzer,SanitizersStatic and dynamic analysis tools for C, C++, and Objective-C code
Coveralls,gcovrLine-by-line test coverage reporting and statistical analysis
Coverity® ScanFind and fix defects in Java, C/C++, C#, JS, Ruby, and Python code
CppcheckStatic analysis tool for C and C++ code
DUMADetect Unintended Memory Access, a memory debugger
FlawfinderScans C and C++ source code for potential security weaknesses
GCC Static AnalyzerCoverage-guided symbolic execution static analyzer for C code
GNU CppiC preprocessor directive linting, indenting, and regularization
GNU GlobalSource code indexing and tagging system
OpenOSCObject size checking library to detect buffer overflows in C/C++ code
Oracle Developer StudioPerformance, security, and thread analysis tools for C, C++, and Fortran
REUSEVerifies compliance with theREUSE licensing guidelines
SemgrepA fast, open-source, static analysis engine for many languages
SonarCloudCloud-based code quality and security analysis tools
ValgrindTools for memory debugging, memory leak detection, and profiling
Visual Studio Code AnalyzerTools to analyze and improve C/C++ source code quality

Additional tools used for libsir development and testing include:

ToolUsage
CBMC,ESBMCBounded Model Checkers for C and C++ programs
Dr. MemoryMemory debugging tool for Windows, Linux, macOS, and Android
FuncheckA tool for checking function call return protections
Frama-CFramework for Modular Analysis of C programs
Intel® VTune™ ProfilerPerformance analysis and profiling tools for Intel systems
Luke StackwalkerSampling C/C++ code profiler for Microsoft Windows
NetBSD lint(1)A C (C90/C99/C11/C17/C23) program verifier
PurifyPlus™Run-time analysis tools for application reliability and performance
ShellCheckA static analysis tool for Unix shell scripts
SmatchSmatch (Source Matcher) is a static analysis tool for C code
SoftIntegration ChC/C++ interpreter and interactive platform for scientific computing
Very SleepySampling CPU profiler for Microsoft Windows applications
VftraceA performance profiling library with a focus on HPC applications

[8]ページ先頭

©2009-2025 Movatter.jp