NeoMutt  2022-04-29-215-gc12b98
Teaching an old dog new tricks
DOXYGEN
logging.h
Go to the documentation of this file.
1
23#ifndef MUTT_LIB_LOGGING_H
24#define MUTT_LIB_LOGGING_H
25
26#include <stdbool.h>
27#include <stdio.h>
28#include <time.h>
29#include "queue.h"
30
35{
36 LL_PERROR = -3,
37 LL_ERROR = -2,
46
48};
49
65typedef int (*log_dispatcher_t)(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, ...);
66
68
72struct LogLine
73{
74 time_t time;
75 const char *file;
76 int line;
77 const char *function;
79 char *message;
81};
82STAILQ_HEAD(LogLineList, LogLine);
83
84#define mutt_debug(LEVEL, ...) MuttLogger(0, __FILE__, __LINE__, __func__, LEVEL, __VA_ARGS__)
85#define mutt_warning(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_WARNING, __VA_ARGS__)
86#define mutt_message(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_MESSAGE, __VA_ARGS__)
87#define mutt_error(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_ERROR, __VA_ARGS__)
88#define mutt_perror(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_PERROR, __VA_ARGS__)
89
90int log_disp_file (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, ...);
91int log_disp_null (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, ...);
92int log_disp_queue (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, ...);
93int log_disp_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, ...);
94
95int log_queue_add(struct LogLine *ll);
96void log_queue_empty(void);
98int log_queue_save(FILE *fp);
99void log_queue_set_max_size(int size);
100
101void log_file_close(bool verbose);
102int log_file_open(bool verbose);
103bool log_file_running(void);
104int log_file_set_filename(const char *file, bool verbose);
105int log_file_set_level(enum LogLevel level, bool verbose);
106void log_file_set_version(const char *version);
107
108#endif /* MUTT_LIB_LOGGING_H */
int log_disp_file(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Save a log line to a file - Implements log_dispatcher_t -.
Definition: logging.c:245
int log_disp_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Save a log line to the terminal - Implements log_dispatcher_t -.
Definition: logging.c:440
log_dispatcher_t MuttLogger
The log dispatcher -.
Definition: logging.c:52
int log_disp_queue(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Save a log line to an internal queue - Implements log_dispatcher_t -.
Definition: logging.c:398
int log_disp_null(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Discard log lines - Implements log_dispatcher_t -.
Definition: logging.c:499
int log_file_open(bool verbose)
Start logging to a file.
Definition: logging.c:119
STAILQ_HEAD(LogLineList, LogLine)
void log_queue_empty(void)
Free the contents of the queue.
Definition: logging.c:324
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
Definition: logging.c:312
int log_file_set_level(enum LogLevel level, bool verbose)
Set the logging level.
Definition: logging.c:175
bool log_file_running(void)
Is the log file running?
Definition: logging.c:229
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition: logging.c:346
int(* log_dispatcher_t)(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Definition: logging.h:65
LogLevel
Names for the Logging Levels.
Definition: logging.h:35
@ LL_DEBUG4
Log at debug level 4.
Definition: logging.h:43
@ LL_ERROR
Log error.
Definition: logging.h:37
@ LL_DEBUG3
Log at debug level 3.
Definition: logging.h:42
@ LL_PERROR
Log perror (using errno)
Definition: logging.h:36
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
@ LL_WARNING
Log warning.
Definition: logging.h:38
@ LL_MESSAGE
Log informational message.
Definition: logging.h:39
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
@ LL_NOTIFY
Log of notifications.
Definition: logging.h:45
@ LL_MAX
Definition: logging.h:47
int log_queue_save(FILE *fp)
Save the contents of the queue to a temporary file.
Definition: logging.c:367
void log_file_close(bool verbose)
Close the log file.
Definition: logging.c:98
int log_file_set_filename(const char *file, bool verbose)
Set the filename for the log.
Definition: logging.c:149
int log_queue_add(struct LogLine *ll)
Add a LogLine to the queue.
Definition: logging.c:285
void log_file_set_version(const char *version)
Set the program's version number.
Definition: logging.c:220
A Log line.
Definition: logging.h:73
const char * file
Source file.
Definition: logging.h:75
char * message
Message to be logged.
Definition: logging.h:79
const char * function
C function.
Definition: logging.h:77
int line
Line number in source file.
Definition: logging.h:76
STAILQ_ENTRY(LogLine) entries
Linked list.
enum LogLevel level
Log level, e.g. LL_DEBUG1.
Definition: logging.h:78
time_t time
Timestamp of the message.
Definition: logging.h:74