NeoMutt  2024-11-14-138-ge5ca67
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 <stdio.h>
28#include <time.h>
29#include "queue.h"
30
32#define LOG_LINE_MAX_LEN 10240
33
38{
39 LL_PERROR = -3,
40 LL_ERROR = -2,
49
51};
52
69typedef int (*log_dispatcher_t)(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
70__attribute__((__format__(__printf__, 6, 7)));
71
73
77struct LogLine
78{
79 time_t time;
80 const char *file;
81 int line;
82 const char *function;
84 char *message;
86};
87STAILQ_HEAD(LogLineList, LogLine);
88
89#define mutt_debug(LEVEL, ...) MuttLogger(0, __FILE__, __LINE__, __func__, LEVEL, __VA_ARGS__)
90#define mutt_warning(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_WARNING, __VA_ARGS__)
91#define mutt_message(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_MESSAGE, __VA_ARGS__)
92#define mutt_error(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_ERROR, __VA_ARGS__)
93#define mutt_perror(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_PERROR, __VA_ARGS__)
94
95void log_multiline_full(enum LogLevel level, const char *str, const char *file, int line, const char *func);
96#define log_multiline(LEVEL, STRING) log_multiline_full(LEVEL, STRING, __FILE__, __LINE__, __func__)
97
98int log_disp_file (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
99 __attribute__((__format__(__printf__, 6, 7)));
100int log_disp_queue (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_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
103 __attribute__((__format__(__printf__, 6, 7)));
104
105int log_queue_add(struct LogLine *ll);
106void log_queue_empty(void);
108int log_queue_save(FILE *fp);
109void log_queue_set_max_size(int size);
110
111void log_file_close(bool verbose);
112int log_file_open(bool verbose);
113bool log_file_running(void);
114int log_file_set_filename(const char *file, bool verbose);
115int log_file_set_level(enum LogLevel level, bool verbose);
116void log_file_set_version(const char *version);
117
118#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:324
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:69
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
Definition: logging.c:312
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:502
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition: logging.c:346
int int int int log_queue_add(struct LogLine *ll)
Add a LogLine to the queue.
Definition: logging.c:285
LogLevel
Names for the Logging Levels.
Definition: logging2.h:38
@ LL_DEBUG4
Log at debug level 4.
Definition: logging2.h:46
@ LL_ERROR
Log error.
Definition: logging2.h:40
@ LL_DEBUG3
Log at debug level 3.
Definition: logging2.h:45
@ LL_PERROR
Log perror (using errno)
Definition: logging2.h:39
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_WARNING
Log warning.
Definition: logging2.h:41
@ LL_MESSAGE
Log informational message.
Definition: logging2.h:42
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:48
@ LL_MAX
Definition: logging2.h:50
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:99
int log_file_set_filename(const char *file, bool verbose)
Set the filename for the log.
Definition: logging.c:150
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:78
const char * file
Source file.
Definition: logging2.h:80
char * message
Message to be logged.
Definition: logging2.h:84
const char * function
C function.
Definition: logging2.h:82
int line
Line number in source file.
Definition: logging2.h:81
STAILQ_ENTRY(LogLine) entries
Linked list.
enum LogLevel level
Log level, e.g. LL_DEBUG1.
Definition: logging2.h:83
time_t time
Timestamp of the message.
Definition: logging2.h:79