naev 0.12.6
log.c File Reference

Home of logprintf. More...

#include "log.h"
#include "conf.h"
#include "debug.h"
#include "ndata.h"
Include dependency graph for log.c:

Go to the source code of this file.

Functions

static int slogprintf (FILE *stream, int newline, const char *str, size_t n)
 va_list version of logprintf and backend.
static int vlogprintf (FILE *stream, int newline, const char *fmt, va_list ap)
 va_list version of logprintf and backend.
static void log_copy (int enable)
 Sets up or terminates copying of standard streams into memory.
static void log_append (const FILE *stream, const char *str)
 Appends a message to a stream's in-memory buffer.
static void log_cleanStream (PHYSFS_File **file, const char *fname, const char *filedouble)
static void log_purge (void)
 Deletes copied output without printing the contents.
int logprintf (FILE *stream, int newline, const char *fmt,...)
 Like fprintf, but automatically teed to log files (and line-terminated if newline is true).
void log_redirect (void)
 Sets up redirection of stdout and stderr to files. PhysicsFS must be initialized for this to work.
void log_init (void)
 Sets up the logging subsystem. (Calling this ensures logging output is preserved until we have a place to save it. That happens after we set up PhysicsFS and call log_redirect().)
void log_clean (void)
 Deletes useless (empty) log files from the current session.
int log_warn (const char *file, size_t line, const char *func, const char *fmt,...)
 Prints warnings, but skips if they are repeated too much.

Variables

static char * outcopy = NULL
static char * errcopy = NULL
static size_t moutcopy
static size_t merrcopy
static int noutcopy = 0
static int nerrcopy = 0
static char * outfiledouble = NULL
static char * errfiledouble = NULL
static int copying = 0
static PHYSFS_File * logout_file = NULL
static PHYSFS_File * logerr_file = NULL

Detailed Description

Home of logprintf.

Definition in file log.c.

Function Documentation

◆ log_append()

void log_append ( const FILE * stream,
const char * str )
static

Appends a message to a stream's in-memory buffer.

Parameters
streamDestination stream (stdout or stderr)
strString to append.

Definition at line 263 of file log.c.

◆ log_clean()

void log_clean ( void )

Deletes useless (empty) log files from the current session.

Definition at line 228 of file log.c.

◆ log_cleanStream()

void log_cleanStream ( PHYSFS_File ** file,
const char * fname,
const char * filedouble )
static
See also
log_clean

Definition at line 237 of file log.c.

◆ log_copy()

void log_copy ( int enable)
static

Sets up or terminates copying of standard streams into memory.

While copying is active, all stdout and stderr-bound messages that pass through logprintf will also be put into a buffer in memory, to be flushed when copying is disabled.

Parameters
enableWhether to enable or disable copying. Disabling flushes logs.

Definition at line 179 of file log.c.

◆ log_init()

void log_init ( void )

Sets up the logging subsystem. (Calling this ensures logging output is preserved until we have a place to save it. That happens after we set up PhysicsFS and call log_redirect().)

See also
log_copy

Definition at line 164 of file log.c.

◆ log_purge()

void log_purge ( void )
static

Deletes copied output without printing the contents.

Definition at line 211 of file log.c.

◆ log_redirect()

void log_redirect ( void )

Sets up redirection of stdout and stderr to files. PhysicsFS must be initialized for this to work.

Definition at line 130 of file log.c.

◆ log_warn()

int log_warn ( const char * file,
size_t line,
const char * func,
const char * fmt,
... )

Prints warnings, but skips if they are repeated too much.

Definition at line 299 of file log.c.

◆ logprintf()

int logprintf ( FILE * stream,
int newline,
const char * fmt,
... )

Like fprintf, but automatically teed to log files (and line-terminated if newline is true).

Definition at line 116 of file log.c.

◆ slogprintf()

int slogprintf ( FILE * stream,
int newline,
const char * str,
size_t n )
static

va_list version of logprintf and backend.

Definition at line 59 of file log.c.

◆ vlogprintf()

int vlogprintf ( FILE * stream,
int newline,
const char * fmt,
va_list ap )
static

va_list version of logprintf and backend.

Definition at line 87 of file log.c.

Variable Documentation

◆ copying

int copying = 0
static

Definition at line 39 of file log.c.

◆ errcopy

char* errcopy = NULL
static

Definition at line 26 of file log.c.

◆ errfiledouble

char* errfiledouble = NULL
static

Definition at line 36 of file log.c.

◆ logerr_file

PHYSFS_File* logerr_file = NULL
static

Definition at line 43 of file log.c.

◆ logout_file

PHYSFS_File* logout_file = NULL
static

Definition at line 42 of file log.c.

◆ merrcopy

size_t merrcopy
static

Definition at line 29 of file log.c.

◆ moutcopy

size_t moutcopy
static

Definition at line 28 of file log.c.

◆ nerrcopy

int nerrcopy = 0
static

Definition at line 32 of file log.c.

◆ noutcopy

int noutcopy = 0
static

Definition at line 31 of file log.c.

◆ outcopy

char* outcopy = NULL
static

< Temporary storage buffers.

Definition at line 25 of file log.c.

◆ outfiledouble

char* outfiledouble = NULL
static

< Output filenames for stdout and stderr.

Definition at line 35 of file log.c.