Thanks to visit codestin.com
Credit goes to code.neomutt.org

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