Ylva And Malin
Macros | Functions
ym_log.h File Reference
#include <ym_attributes.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for ym_log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define YM_COLOR_RESET   "\033[0m"
 
#define YM_COLOR_FG_BLACK   "\033[0;30m"
 
#define YM_COLOR_FG_RED   "\033[0;31m"
 
#define YM_COLOR_FG_GREEN   "\033[0;32m"
 
#define YM_COLOR_FG_YELLOW   "\033[0;33m"
 
#define YM_COLOR_FG_BLUE   "\033[0;34m"
 
#define YM_COLOR_FG_MAGENTA   "\033[0;35m"
 
#define YM_COLOR_FG_CYAN   "\033[0;36m"
 
#define YM_COLOR_FG_GREY   "\033[0;37m"
 
#define YM_COLOR_FG_WHITE   "\033[0m"
 
#define YM_COLOR_BG_BLACK   "\033[0;40m"
 
#define YM_COLOR_BG_RED   "\033[0;41m"
 
#define YM_COLOR_BG_GREEN   "\033[0;42m"
 
#define YM_COLOR_BG_YELLOW   "\033[0;43m"
 
#define YM_COLOR_BG_BLUE   "\033[0;44m"
 
#define YM_COLOR_BG_MAGENTA   "\033[0;45m"
 
#define YM_COLOR_BG_CYAN   "\033[0;46m"
 
#define YM_COLOR_BG_GREY   "\033[0;47m"
 
#define YM_COLOR_BG_WHITE   "\033[0m"
 
#define TERMINAL_PAUSE
 Prints the specified error to stderr and terminates the program. More...
 
#define YM_ERROR(fmt, ...)
 
#define YM_WARN(fmt, ...)   ym_log(stderr, "WARN", YM_COLOR_FG_YELLOW, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
 Prints the specified warning to stderr. More...
 
#define YM_DEBUG(fmt, ...)   ym_log(stdout, "DEBUG", YM_COLOR_FG_CYAN, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
 Prints debug information to stdout. More...
 
#define YM_INFO(fmt, ...)   ym_log(stdout, "INFO", YM_COLOR_FG_WHITE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
 Prints regular info to stdout. More...
 

Functions

void ym_log (FILE *file, const char *type, const char *color, const char *filepath, const char *func, const int line, const char *fmt,...)
 Actual function which is called by log macros. More...
 

Macro Definition Documentation

#define YM_COLOR_BG_BLACK   "\033[0;40m"
#define YM_COLOR_BG_BLUE   "\033[0;44m"
#define YM_COLOR_BG_CYAN   "\033[0;46m"
#define YM_COLOR_BG_GREEN   "\033[0;42m"
#define YM_COLOR_BG_GREY   "\033[0;47m"
#define YM_COLOR_BG_MAGENTA   "\033[0;45m"
#define YM_COLOR_BG_RED   "\033[0;41m"
#define YM_COLOR_BG_WHITE   "\033[0m"
#define YM_COLOR_BG_YELLOW   "\033[0;43m"
#define YM_COLOR_FG_BLACK   "\033[0;30m"
#define YM_COLOR_FG_BLUE   "\033[0;34m"
#define YM_COLOR_FG_CYAN   "\033[0;36m"
#define YM_COLOR_FG_GREEN   "\033[0;32m"
#define YM_COLOR_FG_GREY   "\033[0;37m"
#define YM_COLOR_FG_MAGENTA   "\033[0;35m"
#define YM_COLOR_FG_RED   "\033[0;31m"
#define YM_COLOR_FG_WHITE   "\033[0m"
#define YM_COLOR_FG_YELLOW   "\033[0;33m"
#define YM_COLOR_RESET   "\033[0m"
#define YM_ERROR (   fmt,
  ... 
)
Value:
{ \
ym_log(stderr, "ERROR", YM_COLOR_FG_RED, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
exit(EXIT_FAILURE); \
}
void ym_log(FILE *file, const char *type, const char *color, const char *filepath, const char *func, const int line, const char *fmt,...)
Actual function which is called by log macros.
Definition: ym_log.c:7
#define YM_COLOR_FG_RED
Definition: ym_log.h:32
#define TERMINAL_PAUSE
Prints the specified error to stderr and terminates the program.
Definition: ym_log.h:99

Function Documentation

void ym_log ( FILE *  file,
const char *  type,
const char *  color,
const char *  filepath,
const char *  func,
const int  line,
const char *  fmt,
  ... 
)

Actual function which is called by log macros.

Note
Do not use this function! You are supposed to use the logger macros.
Todo:
Add timing functionality.
Todo:
Make proper buffered logger which does not require a lock. But rather logs to a specified location, and is later printed out by the debug thread.