-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
87 additions
and
32 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "log.h" | ||
|
||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <stdarg.h> | ||
#include <syslog.h> | ||
#include <string.h> | ||
|
||
void log_printf(struct logger *logger, enum log_level level, const char *format, ...) | ||
{ | ||
char p[1024]; | ||
va_list ap; | ||
va_start(ap, format); | ||
(void)vsnprintf(p, 1024, format, ap); | ||
va_end(ap); | ||
fprintf(stderr, "%s, %s", logger->name, p); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef __LOG_H__ | ||
#define __LOG_H__ | ||
|
||
#ifdef __cplusplus | ||
/* *INDENT-OFF* */ | ||
extern "C" { | ||
/* *INDENT-ON* */ | ||
#endif | ||
|
||
struct logger { | ||
char *name; | ||
int verbose; | ||
}; | ||
|
||
enum log_level { | ||
ERR, | ||
WARNING, | ||
NOTICE, | ||
INFO, | ||
DEBUG | ||
}; | ||
|
||
void log_printf(struct logger *logger, enum log_level level, const char *format, ...); | ||
|
||
#ifdef __cplusplus | ||
/* *INDENT-OFF* */ | ||
} | ||
/* *INDENT-ON* */ | ||
#endif | ||
#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
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