Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Created by hyotiger on 12/14/18.
- //
- //
- // Created by hyotiger on 12/13/18.
- //
- #include <stdio.h>
- #include <stdarg.h>
- #include "simplog.h"
- static unsigned int simplog_run_level = SIMP_LOG_LVL_NEVER;
- static const char * simplog_level_strings [] = {
- "NONE", // 0
- " ERR", // 1
- "WARN", // 2
- "INFO", // 3
- " DBG", // 4
- " ALL" // 5
- };
- static void simplog_write(int level, const char *funcname, unsigned int linenum, const char *str, ...)
- {
- va_list args;
- va_start(args, str);
- if ( level <= simplog_run_level) {
- char fmt[1024];
- snprintf(fmt, sizeof(fmt), "[%s %s:%d] %s\n", simplog_level_strings[level], funcname, linenum, str);
- vfprintf( stdout, fmt, args);
- }
- va_end( args );
- }
- static void simplog_set_loglevel(unsigned char level) {
- fprintf(stdout, "[SIMPLOG] LOG level is changed from %s to %s\n", simplog_level_strings[simplog_run_level], simplog_level_strings[level]);
- simplog_run_level = level;
- }
- simplelog_namespace const simplog = {
- .SetLogLevel = simplog_set_loglevel,
- .WriteLog = simplog_write,
- };
Add Comment
Please, Sign In to add comment