NeoMutt
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
95int log_disp_file (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
96 __attribute__((__format__(__printf__, 6, 7)));
97int log_disp_null (time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
98 __attribute__((__format__(__printf__, 6, 7)));
99int log_disp_queue (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_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format, ...)
102 __attribute__((__format__(__printf__, 6, 7)));
103
104int log_queue_add(struct LogLine *ll);
105void log_queue_empty(void);
107int log_queue_save(FILE *fp);
108void log_queue_set_max_size(int size);
109
110void log_file_close(bool verbose);
111int log_file_open(bool verbose);
112bool log_file_running(void);
113int log_file_set_filename(const char *file, bool verbose);
114int log_file_set_level(enum LogLevel level, bool verbose);
115void log_file_set_version(const char *version);
116
117#endif /* MUTT_MUTT_LOGGING2_H */
int log_file_open(bool verbose)
Start logging to a file.
Definition: logging.c:119
int 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__
void log_queue_empty(void)
Free the contents of the queue.
Definition: logging.c:323
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:311
int int int int int log_queue_add(struct LogLine *ll)
Add a LogLine to the queue.
Definition: logging.c:284
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
int 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)
int int log_disp_null(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...) __attribute__((__format__(__printf__
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition: logging.c:345
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:366
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
void log_file_set_version(const char *version)
Set the program's version number.
Definition: logging.c:220
#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