Skip to content

Navigation Menu

Sign in
Appearance settings

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

Appearance settings

febits/loguva

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loguva

Loguva (Log + Uva) is a library that provides a simple and lightweight interface for logging.

Features:

  • Multiple log destinations.
  • Multiple log levels.
  • Fancy stdout.

Installation

git clone https://github.com/febits/loguva
cd loguva
make
sudo make install

Samples

make samples

Loguva Print to STDOUT

Usage

Firstly, you need to include the main header file: loguva.h. Don't forget to pass the -lloguva to the linker.

Basically, the loguva allows adding up to 20 instances of FILE * by calling one of the following functions below:

bool loguva_add_stream(FILE *stream);
FILE *loguva_add_file(const char *path);

Once you call the macro below passing the log level and the message, you are logging:

#define loguva(lv, fmt, ...)                                                   \
  loguva_log(lv, __FILE__, __LINE__, fmt, ##__VA_ARGS__)

Log levels:

enum log_levels { DEBUG, INFO, WARNING, ERROR, FATAL };

Let's suppose that you want to log both STDOUT and some FILE *:

#include <loguva.h>

int main(void) {
    
    loguva_add_stream(stdout);
    loguva_add_file("/tmp/loguva.log");

    int x = 50;

    loguva(DEBUG, "The value of X: %d", x);

    return 0;
}

When you call loguva(), all instances of FILE * will be used to write the full log message. As you can see above, both STDOUT and /tmp/loguva.log.

References

About

A tiny and lightweight log library written in C

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.