Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LeaoMartelo2/LogNest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogNest

A Simple yet customizable header only library for logging in C.

image Image depicting the dafault configuration result

Installing:

Note

This is a macro heavy library, do of that what you will.

wget https://raw.githubusercontent.com/LeaoMartelo2/LogNest/main/lognest.h

just copy this if you are lazy

Usage:

(Please refer to the examples if needed)

  • Download lognest.h and add it to your project.
  • #define the settings for your program ONLY in one file.
  • Add #define LOGNEST_IMPLEMENTATION before including it ONLY in one file (the same you configured on).
  • #include lognest.h normally and in any other file you need.

Configuration:

  • Disable any specific log level with:
#define LOGNEST_DISABLE_<TRACE/WARN/ERROR/DEBUG>

Pairs great with -DLOGNEST_DISABLE_ on compile flags

  • Change any log level identifier prefix with :
#define LOGNEST_<TRACE/WARN/ERROR/DEBUG>_PREFIX "<custom prefix>"

The separators ([]) around the type must also be included here.

  • Optionally change where the log file path with:
#define LOGNEST_FILE "path/to/log/filename.log"

Defaults to latest.log

  • Optionally disable the log's time or date of message with:
#define LOGNEST_DISABLE_TIMESTAMP
/* or */
#define LOGNEST_DISABLE_DATESTAMP
  • Optionally allow crashing on error with:
#define LOGNEST_ALLOW_CRASH
  • Some other misc configurations can be changed with:
#define LOGNEST_ABORT()
/* uses stdlib's abort() for crashing */
#define LOGNEST_API
/* added before every function definition, use it to add stuff like `static inline` on single file projects */

image

Latest update changes:

LogNest 2.1.6

  • Fix issue with LOGNEST_API macro causing some issues with its defult behaviour, now its up to the user to enable it.
  • Add macro to replace force exiting / crashing on error function with your own.

About

Simple header only library in C for logging

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages