naev 0.10.4
log.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include <signal.h>
8#include <stdio.h>
9
10#include "gettext.h"
13#include "nstring.h"
14
15#define LOG(str, args...) (logprintf(stdout, 1, str, ## args))
16#define LOGERR(str, args...) (logprintf(stderr, 1, str, ## args))
17#ifdef DEBUG_PARANOID /* Will cause WARNs to blow up */
18#define WARN(str, args...) (logprintf(stderr, 0, _("WARNING %s:%d [%s]: "), __FILE__, __LINE__, __func__), logprintf( stderr, 1, str, ## args), raise(SIGINT))
19#else /* DEBUG_PARANOID */
20#define WARN(str, args...) (logprintf(stderr, 0, _("Warning: [%s] "), __func__), logprintf( stderr, 1, str, ## args))
21#endif /* DEBUG_PARANOID */
22#define ERR(str, args...) (logprintf(stderr, 0, _("ERROR %s:%d [%s]: "), __FILE__, __LINE__, __func__), logprintf( stderr, 1, str, ## args), abort())
23#ifdef DEBUG
24# undef DEBUG
25# define DEBUG(str, args...) LOG(str, ## args)
26# ifndef DEBUGGING
27# define DEBUGGING 1
28# endif /* DEBUGGING */
29#else /* DEBUG */
30# define DEBUG(str, args...) do {;} while (0)
31#endif /* DEBUG */
32#define DEBUG_BLANK() DEBUG("%s", "")
33
34PRINTF_FORMAT( 3, 4 ) NONNULL(3) int logprintf( FILE *stream, int newline, const char *fmt, ... );
35void log_init (void);
36void log_redirect (void);
37void log_clean (void);
void log_clean(void)
Deletes useless (empty) log files from the current session.
Definition: log.c:205
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: log.c:56
void log_init(void)
Sets up the logging subsystem. (Calling this ensures logging output is preserved until we have a plac...
Definition: log.c:142
void log_redirect(void)
Sets up redirection of stdout and stderr to files. PhysicsFS must be initialized for this to work.
Definition: log.c:108