102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
log.c File Reference
#include <dttr_log.h>
#include <stdarg.h>
#include <stdio.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  log_callback

Macros

#define MAX_CALLBACKS   32

Functions

static const char * level_to_string (int level)
static void init_event (log_Event *ev, void *udata)
static void stderr_callback (log_Event *ev)
static void file_callback (log_Event *ev)
bool DTTR_Log_IsEnabled (int log_level)
static void dttr_vlog_unchecked (int log_level, const char *file, int line, const char *fmt, va_list args)
void DTTR_Log (int level, const char *file, int line, const char *fmt,...)
void DTTR_Log_Unchecked (int level, const char *file, int line, const char *fmt,...)
void DTTR_Log_SetLevel (int log_level)
static int add_log_callback (log_LogFn fn, void *udata, int level)
int DTTR_Log_AddFP (FILE *fp, int level)

Variables

static int current_log_level = LOG_TRACE
static log_callback callbacks [MAX_CALLBACKS]
static int callback_count

Macro Definition Documentation

◆ MAX_CALLBACKS

#define MAX_CALLBACKS   32

Definition at line 7 of file log.c.

Referenced by add_log_callback().

Function Documentation

◆ add_log_callback()

int add_log_callback ( log_LogFn fn,
void * udata,
int level )
static

Definition at line 147 of file log.c.

References callback_count, callbacks, and MAX_CALLBACKS.

Referenced by DTTR_Log_AddFP().

◆ DTTR_Log()

void DTTR_Log ( int level,
const char * file,
int line,
const char * fmt,
... )

Definition at line 125 of file log.c.

References DTTR_Log_IsEnabled(), dttr_vlog_unchecked(), and fmt.

◆ DTTR_Log_AddFP()

int DTTR_Log_AddFP ( FILE * fp,
int level )

Definition at line 161 of file log.c.

References add_log_callback(), and file_callback().

Referenced by DTTR_Hook_WinMainCallback(), and open_log_file().

◆ DTTR_Log_IsEnabled()

bool DTTR_Log_IsEnabled ( int log_level)

Definition at line 79 of file log.c.

References callback_count, callbacks, and current_log_level.

Referenced by DTTR_Log().

◆ DTTR_Log_SetLevel()

void DTTR_Log_SetLevel ( int log_level)

Definition at line 143 of file log.c.

References current_log_level.

Referenced by DTTR_Hook_WinMainCallback(), and dttr_launcher_main().

◆ DTTR_Log_Unchecked()

void DTTR_Log_Unchecked ( int level,
const char * file,
int line,
const char * fmt,
... )

Definition at line 136 of file log.c.

References dttr_vlog_unchecked(), and fmt.

◆ dttr_vlog_unchecked()

void dttr_vlog_unchecked ( int log_level,
const char * file,
int line,
const char * fmt,
va_list args )
static

Definition at line 93 of file log.c.

References callback_count, callbacks, cb, current_log_level, fmt, init_event(), and stderr_callback().

Referenced by DTTR_Log(), and DTTR_Log_Unchecked().

◆ file_callback()

void file_callback ( log_Event * ev)
static

Definition at line 63 of file log.c.

References level_to_string().

Referenced by DTTR_Log_AddFP().

◆ init_event()

void init_event ( log_Event * ev,
void * udata )
static

Definition at line 38 of file log.c.

References NULL.

Referenced by dttr_vlog_unchecked().

◆ level_to_string()

const char * level_to_string ( int level)
static

Definition at line 19 of file log.c.

Referenced by file_callback(), and stderr_callback().

◆ stderr_callback()

void stderr_callback ( log_Event * ev)
static

Definition at line 47 of file log.c.

References level_to_string().

Referenced by dttr_vlog_unchecked().

Variable Documentation

◆ callback_count

int callback_count
static

Definition at line 17 of file log.c.

Referenced by add_log_callback(), DTTR_Log_IsEnabled(), and dttr_vlog_unchecked().

◆ callbacks

log_callback callbacks[MAX_CALLBACKS]
static

Definition at line 16 of file log.c.

Referenced by add_log_callback(), DTTR_Log_IsEnabled(), and dttr_vlog_unchecked().

◆ current_log_level

int current_log_level = LOG_TRACE
static

Definition at line 15 of file log.c.

Referenced by DTTR_Log_IsEnabled(), DTTR_Log_SetLevel(), and dttr_vlog_unchecked().