Trace Engine
A Raycaster Engine in C
Loading...
Searching...
No Matches
log.c File Reference
#include "log.h"
#include <stdio.h>
#include <stdarg.h>
#include <time.h>

Data Structures

struct  message_info
 

Macros

#define ANSI_COLOR_RED   "\x1b[31m"
 
#define ANSI_COLOR_GREEN   "\x1b[32m"
 
#define ANSI_COLOR_YELLOW   "\x1b[33m"
 
#define ANSI_COLOR_CYAN   "\x1b[36m"
 
#define ANSI_COLOR_WHITE   "\x1b[37m"
 
#define ANSI_COLOR_GREY   "\x1b[90m"
 
#define ANSI_COLOR_RESET   "\x1b[0m"
 
#define ANSI_BOLD   "\e[1m"
 
#define DATA_COLOR   ANSI_COLOR_GREY
 
#define DEBUG_COLOR   ANSI_COLOR_GREEN
 
#define INFO_COLOR   ANSI_COLOR_CYAN
 
#define WARNING_COLOR   ANSI_COLOR_YELLOW
 
#define ERROR_COLOR   ANSI_COLOR_RED ANSI_BOLD
 

Functions

void print_message (const message_info info, const char *message, va_list arg)
 
void log_message (const log_levels_t log_level, const char *file_name, const int line, const char *message,...)
 

Macro Definition Documentation

◆ ANSI_BOLD

#define ANSI_BOLD   "\e[1m"

◆ ANSI_COLOR_CYAN

#define ANSI_COLOR_CYAN   "\x1b[36m"

◆ ANSI_COLOR_GREEN

#define ANSI_COLOR_GREEN   "\x1b[32m"

◆ ANSI_COLOR_GREY

#define ANSI_COLOR_GREY   "\x1b[90m"

◆ ANSI_COLOR_RED

#define ANSI_COLOR_RED   "\x1b[31m"

◆ ANSI_COLOR_RESET

#define ANSI_COLOR_RESET   "\x1b[0m"

◆ ANSI_COLOR_WHITE

#define ANSI_COLOR_WHITE   "\x1b[37m"

◆ ANSI_COLOR_YELLOW

#define ANSI_COLOR_YELLOW   "\x1b[33m"

◆ DATA_COLOR

#define DATA_COLOR   ANSI_COLOR_GREY

◆ DEBUG_COLOR

#define DEBUG_COLOR   ANSI_COLOR_GREEN

◆ ERROR_COLOR

#define ERROR_COLOR   ANSI_COLOR_RED ANSI_BOLD

◆ INFO_COLOR

#define INFO_COLOR   ANSI_COLOR_CYAN

◆ WARNING_COLOR

#define WARNING_COLOR   ANSI_COLOR_YELLOW

Function Documentation

◆ log_message()

void log_message ( const log_levels_t  log_level,
const char *  file_name,
const int  line,
const char *  message,
  ... 
)

Prints to the standard output the given message formated with the given parameters.

Parameters
log_levelThe message importance level, this is used to include a keyword (DEBUG, INFO, WARNING and ERROR)
file_nameThe file name of the caller
lineThe line of the call
messageThe text to print

◆ print_message()

void print_message ( const message_info  info,
const char *  message,
va_list  arg 
)