|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <sys/time.h>#include "log.h"Go to the source code of this file.
Macros | |
| #define | _POSIX_C_SOURCE 200112L |
| #define | LOG_STATE_UNINITIALIZED 0 |
| #define | LOG_STATE_INITIALIZING 1 |
| #define | LOG_STATE_READY 2 |
| #define | LOG_LEVEL_NONE (-1) |
| #define | LOG_STACK_BUFFER_SIZE 1024 |
Functions | |
| static int | log_state_claim (void) |
| static long | log_state_load (void) |
| static void | log_state_store (long value) |
| static int | log_strcasecmp (const char *a, const char *b) |
| static void | log_init (void) |
| Resolves the logging configuration from the environment, exactly once per process. | |
| static const char * | log_short_path (const char *file) |
| Strips the build-machine directory from FILE, keeping the path below src/ if present. | |
| static int | log_timestamp (char *buf, size_t size) |
| void | aaru_log_write (int level, const char *file, int line, const char *func, const char *fmt,...) |
| Writes one log line. | |
| void | aaru_log_reset (void) |
Variables | |
| static volatile long | log_state = 0 |
| static FILE * | log_stream = NULL |
| static int | log_level = 1 |
| #define LOG_LEVEL_NONE (-1) |
Definition at line 41 of file log.c.
Referenced by log_init().
| #define LOG_STACK_BUFFER_SIZE 1024 |
Definition at line 43 of file log.c.
Referenced by aaru_log_write().
| #define LOG_STATE_INITIALIZING 1 |
Definition at line 38 of file log.c.
Referenced by log_state_claim().
| #define LOG_STATE_READY 2 |
Definition at line 39 of file log.c.
Referenced by aaru_log_reset(), and log_init().
| #define LOG_STATE_UNINITIALIZED 0 |
Definition at line 37 of file log.c.
Referenced by aaru_log_reset(), and log_state_claim().
| void aaru_log_reset | ( | void | ) |
Definition at line 229 of file log.c.
References aaru_log_reset(), AARU_LOG_TRACE, log_level, log_state_load(), LOG_STATE_READY, log_state_store(), LOG_STATE_UNINITIALIZED, and log_stream.
Referenced by aaru_log_reset().
| void aaru_log_write | ( | int | level, |
| const char * | file, | ||
| int | line, | ||
| const char * | func, | ||
| const char * | fmt, | ||
| ... ) |
Writes one log line.
Called through the TRACE and FATAL macros in log.h.
The whole line is formatted into a buffer and emitted with a single fwrite(), which stdio locks per call, so lines from concurrent threads do not interleave.
Definition at line 173 of file log.c.
References AARU_LOG_FATAL, aaru_log_write(), log_init(), log_level, log_short_path(), LOG_STACK_BUFFER_SIZE, log_stream, and log_timestamp().
Referenced by aaru_log_write().
|
static |
Resolves the logging configuration from the environment, exactly once per process.
AARUFORMAT_LOG_LEVEL selects "trace" (default), "fatal" or "none". AARUFORMAT_LOG_FILE names a file to append to; if unset or unopenable, stderr is used.
Definition at line 93 of file log.c.
References AARU_LOG_FATAL, AARU_LOG_TRACE, log_init(), log_level, LOG_LEVEL_NONE, log_state_claim(), log_state_load(), LOG_STATE_READY, log_state_store(), log_strcasecmp(), and log_stream.
Referenced by aaru_log_write(), and log_init().
|
static |
Strips the build-machine directory from FILE, keeping the path below src/ if present.
Definition at line 130 of file log.c.
References log_short_path().
Referenced by aaru_log_write(), and log_short_path().
|
static |
Definition at line 64 of file log.c.
References log_state, log_state_claim(), LOG_STATE_INITIALIZING, and LOG_STATE_UNINITIALIZED.
Referenced by log_init(), and log_state_claim().
|
static |
Definition at line 70 of file log.c.
References log_state, and log_state_load().
Referenced by aaru_log_reset(), log_init(), and log_state_load().
|
static |
Definition at line 71 of file log.c.
References log_state, and log_state_store().
Referenced by aaru_log_reset(), log_init(), and log_state_store().
|
static |
Definition at line 74 of file log.c.
References log_strcasecmp().
Referenced by log_init(), and log_strcasecmp().
|
static |
Definition at line 149 of file log.c.
References log_timestamp().
Referenced by aaru_log_write(), and log_timestamp().
|
static |
Definition at line 47 of file log.c.
Referenced by aaru_log_reset(), aaru_log_write(), and log_init().
|
static |
Definition at line 45 of file log.c.
Referenced by log_state_claim(), log_state_load(), and log_state_store().
|
static |
Definition at line 46 of file log.c.
Referenced by aaru_log_reset(), aaru_log_write(), and log_init().