naev
0.11.5
src
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, ...) (logprintf(stdout, 1, str, ## __VA_ARGS__))
16
#define LOGERR(str, ...) (logprintf(stderr, 1, str, ## __VA_ARGS__))
17
#ifdef DEBUG_PARANOID
/* Will cause WARNs to blow up */
18
#define WARN(str, ...) (logprintf(stderr, 0, _("WARNING %s:%d [%s]: "), __FILE__, __LINE__, __func__), logprintf( stderr, 1, str, ## __VA_ARGS__), raise(SIGINT))
19
#else
/* DEBUG_PARANOID */
20
#define WARN(str, ...) (logprintf(stderr, 0, _("Warning: [%s] "), __func__), logprintf( stderr, 1, str, ## __VA_ARGS__))
21
#endif
/* DEBUG_PARANOID */
22
#define ERR(str, ...) (logprintf(stderr, 0, _("ERROR %s:%d [%s]: "), __FILE__, __LINE__, __func__), logprintf( stderr, 1, str, ## __VA_ARGS__), abort())
23
#ifdef DEBUG
24
# undef DEBUG
25
# define DEBUG(str, ...) LOG(str, ## __VA_ARGS__)
26
# ifndef DEBUGGING
27
# define DEBUGGING 1
28
# endif
/* DEBUGGING */
29
#else
/* DEBUG */
30
# define DEBUG(str, ...) do {;} while (0)
31
#endif
/* DEBUG */
32
#define DEBUG_BLANK() DEBUG("%s", "")
33
34
PRINTF_FORMAT( 3, 4 ) NONNULL(3)
int
logprintf
( FILE *stream,
int
newline, const
char
*fmt, ... );
35
void
log_init (
void
);
36
void
log_redirect (
void
);
37
void
log_clean (
void
);
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
log.c:56
Generated by
1.12.0