naev 0.11.5
log.c File Reference

Home of logprintf. More...

#include "log.h"
#include "conf.h"
#include "ndata.h"
#include "nstring.h"

Go to the source code of this file.

Functions

static void log_copy (int enable)
 Sets up or terminates copying of standard streams into memory.
 
static void log_append (FILE *stream, 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.
 

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()

static void log_append ( FILE * stream,
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 239 of file log.c.

◆ log_clean()

void log_clean ( void )

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

Definition at line 205 of file log.c.

◆ log_cleanStream()

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

Definition at line 214 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 156 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 142 of file log.c.

◆ log_purge()

static void log_purge ( void )
static

Deletes copied output without printing the contents.

Definition at line 188 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 108 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 56 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.