NeoMutt  2025-01-09-117-gace867
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
logging2.h
Go to the documentation of this file.
1
23#ifndef MUTT_MUTT_LOGGING2_H
24#define MUTT_MUTT_LOGGING2_H
25
26#include <stdbool.h>
27#include <time.h>
28#include "queue.h"
29
31#define LOG_LINE_MAX_LEN 10240
32
33extern const char *LogLevelAbbr;
34
39{
40 LL_PERROR = -3,
41 LL_ERROR = -2,
50
52};
53
70typedef int (*log_dispatcher_t)(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
71__attribute__((__format__(__printf__, 6, 7)));
72
74
78struct LogLine
79{
80 time_t time;
81 const char *file;
82 int line;
83 const char *function;
85 char *message;
87};
88STAILQ_HEAD(LogLineList, LogLine);
89
90#define mutt_debug(LEVEL, ...) MuttLogger(0, __FILE__, __LINE__, __func__, LEVEL, __VA_ARGS__)
91#define mutt_warning(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_WARNING, __VA_ARGS__)
92#define mutt_message(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_MESSAGE, __VA_ARGS__)
93#define mutt_error(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_ERROR, __VA_ARGS__)
94#define mutt_perror(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_PERROR, __VA_ARGS__)
95
96void log_multiline_full(enum LogLevel level, const char *str, const char *file, int line, const char *func);
97#define log_multiline(LEVEL, STRING) log_multiline_full(LEVEL, STRING, __FILE__, __LINE__, __func__)
98
99int log_disp_file (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
100 __attribute__((__format__(__printf__, 6, 7)));
101int log_disp_queue (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
102 __attribute__((__format__(__printf__, 6, 7)));
103int log_disp_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
104 __attribute__((__format__(__printf__, 6, 7)));
105
106int log_queue_add(struct LogLine *ll);
107void log_queue_empty(void);
109const struct LogLineList log_queue_get(void);
110void log_queue_set_max_size(int size);
111
112void log_file_close(bool verbose);
113int log_file_open(bool verbose);
114bool log_file_running(void);
115int log_file_set_filename(const char *file, bool verbose);
116int log_file_set_level(enum LogLevel level, bool verbose);
117void log_file_set_version(const char *version);
118
119#endif /* MUTT_MUTT_LOGGING2_H */
int log_file_open(bool verbose)
Start logging to a file.
Definition: logging.c:120
void log_queue_empty(void)
Free the contents of the queue.
Definition: logging.c:325
int log_disp_file(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...) __attribute__((__format__(__printf__
int(* log_dispatcher_t)(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...) __attribute__((__format__(__printf__
Definition: logging2.h:70
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
Definition: logging.c:313
int int log_disp_queue(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...) __attribute__((__format__(__printf__
int log_file_set_level(enum LogLevel level, bool verbose)
Set the logging level.
Definition: logging.c:176
bool log_file_running(void)
Is the log file running?
Definition: logging.c:230
int int int log_disp_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...) __attribute__((__format__(__printf__
int(*) log_dispatcher_ MuttLogger)
void log_multiline_full(enum LogLevel level, const char *str, const char *file, int line, const char *func)
Helper to dump multiline text to the log.
Definition: logging.c:482
const struct LogLineList log_queue_get(void)
Get the Log Queue.
Definition: logging.c:362
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition: logging.c:347
int int int int log_queue_add(struct LogLine *ll)
Add a LogLine to the queue.
Definition: logging.c:286
LogLevel
Names for the Logging Levels.
Definition: logging2.h:39
@ LL_DEBUG4
Log at debug level 4.
Definition: logging2.h:47
@ LL_ERROR
Log error.
Definition: logging2.h:41
@ LL_DEBUG3
Log at debug level 3.
Definition: logging2.h:46
@ LL_PERROR
Log perror (using errno)
Definition: logging2.h:40
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:48
@ LL_WARNING
Log warning.
Definition: logging2.h:42
@ LL_MESSAGE
Log informational message.
Definition: logging2.h:43
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:45
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:44
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:49
@ LL_MAX
Definition: logging2.h:51
void log_file_close(bool verbose)
Close the log file.
Definition: logging.c:99
int log_file_set_filename(const char *file, bool verbose)
Set the filename for the log.
Definition: logging.c:150
const char * LogLevelAbbr
Abbreviations of logging level names.
Definition: logging.c:46
void log_file_set_version(const char *version)
Set the program's version number.
Definition: logging.c:221
#define STAILQ_HEAD(name, type)
Definition: queue.h:312
A Log line.
Definition: logging2.h:79
const char * file
Source file.
Definition: logging2.h:81
char * message
Message to be logged.
Definition: logging2.h:85
const char * function
C function.
Definition: logging2.h:83
int line
Line number in source file.
Definition: logging2.h:82
STAILQ_ENTRY(LogLine) entries
Linked list.
enum LogLevel level
Log level, e.g. LL_DEBUG1.
Definition: logging2.h:84
time_t time
Timestamp of the message.
Definition: logging2.h:80