-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support log level and two print method
- Loading branch information
Showing
4 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
clog | ||
==== | ||
|
||
A useful log | ||
A useful log with color | ||
|
||
Advantage: | ||
* Small footprint. | ||
* Enable color print with a define in CFLAGS -DCOLOR_LOG. | ||
* Display the log time unit in ms. | ||
* Support log to file | ||
* Support log level filter | ||
* Support LOG($LEVEL, ""...) and LOG_$LEVEL(""...) both method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
#ifndef __LOG_H | ||
#define __LOG_H | ||
|
||
#define LOG_FATAL 4 | ||
#define LOG_ERROR 3 | ||
#define LOG_WARN 2 | ||
#define LOG_INFO 1 | ||
#define LOG_DEBUG 0 | ||
#define FATAL 4 | ||
#define ERROR 3 | ||
#define WARN 2 | ||
#define INFO 1 | ||
#define DEBUG 0 | ||
void log_print(int level, char *file, int line, char *fmt, ...); | ||
#define LOG(level, fmt, args...) log_print(level, __FILE__,__LINE__, fmt, ##args) | ||
|
||
#define LOG_DEBUG(fmt, args...) log_print(DEBUG, __FILE__,__LINE__, fmt, ##args) | ||
#define LOG_INFO(fmt, args...) log_print(INFO, __FILE__,__LINE__, fmt, ##args) | ||
#define LOG_WARN(fmt, args...) log_print(WARN, __FILE__,__LINE__, fmt, ##args) | ||
#define LOG_ERROR(fmt, args...) log_print(ERROR, __FILE__,__LINE__, fmt, ##args) | ||
#define LOG_FATAL(fmt, args...) log_print(FATAL, __FILE__,__LINE__, fmt, ##args) | ||
|
||
|
||
int log_set_file(char *file); | ||
int log_close_file(); | ||
|
||
int log_set_level(int level); | ||
int log_set_opt(int opt); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters