rxi / log.c Goto Github PK
View Code? Open in Web Editor NEWA simple logging library implemented in C99
License: MIT License
A simple logging library implemented in C99
License: MIT License
Line 38 in f9ea349
Is thread safe ?
can it use in multi threads ?
I'm trying to implement it to my project but I'm facing difficulties due to the improper documentation and the functions that are not explained in it.
rn i have
log_add_callback((void*)log_callback, (void *)0, LOG_ERROR);
but wtf do i put in place of the udata and log level?
I want to write logging messages to a text file, here is what i have done.
FILE *fp_test = fopen("logging.txt","w");
log_add_fp(fp_test,"INFO");
log_info("%s is good man","rxi");
fclose(fp_test);
But i got an empty file logging.txt.
How to achieve this?
Is there any way to send the longs through syslog for background services?
Should the lock be locked before changing level, for the case where the log level is configurable during runtime?
I want to open a single file, for example xxxx.txt, to record all the logs including all levels generated from different modules or C files.
Hello,
I wanted to ask what happens when log file reaches maximum size of fatfs (2^32 - 1).
FatFS just stops writing into file and in the library I cannot find if it's possible to set maximum size of the log file, reaching which it would start overwriting from the begging of the file
or this functionality is not foreseen or needs yet to be implemented?
thank you
You can't use an internal locking-unlocking system, because you should disable interruptions during lock or unlock execution (it's not possible with CPU in user-mode). So you can include pthread and use a mutex. Let me know for a pull-request.
log_trace("%s", NULL);
output is (null)
but according to standard C library usage states NULL argument behaivour is undefined. So passing NULL to functions like printf() could produce Segmentation Fault.
It would be nice to be able to log NULLs without worries.
How to use this function in a new c program.
Hi,
Maybe you consider changing log level names inside enum in log.h (LOG_INFO, LOG_ERROR etc.). Some of the decleration also used in linux syslog utility and that leads confisuon. For example, LOG_INFO also defined in syslog and has value 6 despite your utility's LOG_INFO has number 2.
Best regards,
Said.
Apparently you changed the copyright year from 2017 to 2020 but the year of first publication should be set out. It is a common misconception that the current year should always be given.
The general rule is that the year to include in a copyright notice is the year of first publication of the work. First publication is when the work is made available to the public without restriction. This includes selling a book or leaving free copies of it in a public place or posting content on your blog. Publication does not include, for example, circulating copies internally to co-workers or sending copies of a book to a publisher.
For compilations or derivative works which incorporate previously published content, the year of first publication of the compilation or derivative work is sufficient.
Source: Which Year Should You Use in Your Copyright Notice?
Best regards, Michael
Is this library multithreaded safe?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.