79 static char buf[23] = { 0 };
80 static time_t last = 0;
104 fprintf(
LogFileFP,
"# vim: syntax=neomuttlog\n");
206 " Logging at this level can reveal personal information.\n" 207 " Review the log carefully before posting in bug reports.\n" 247 const char *
function,
enum LogLevel level, ...)
256 function =
"UNKNOWN";
263 const char *fmt = va_arg(ap,
const char *);
269 fprintf(
LogFileFP,
": %s\n", strerror(err));
403 char buf[1024] = { 0 };
408 const char *fmt = va_arg(ap,
const char *);
409 int ret = vsnprintf(buf,
sizeof(buf), fmt, ap);
414 ret += snprintf(buf + ret,
sizeof(buf) - ret,
": %s", strerror(err));
451 const char *fmt = va_arg(ap,
const char *);
452 int ret = vsnprintf(buf,
sizeof(buf), fmt, ap);
455 log_disp_file(stamp, file, line,
function, level,
"%s", buf);
457 FILE *fp = (level <
LL_MESSAGE) ? stderr : stdout;
460 bool tty = (isatty(fileno(fp)) == 1);
488 ret += fprintf(fp,
"\033[1;%dm", colour);
493 ret += fprintf(fp,
": %s", strerror(err));
496 ret += fprintf(fp,
"\033[0m");
498 ret += fprintf(fp,
"\n");
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.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
void log_file_close(bool verbose)
Close the log file.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
#define STAILQ_REMOVE(head, elm, type, field)
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
enum LogLevel level
Log level, e.g. LL_DEBUG1.
Memory management wrappers.
const char * LevelAbbr
Abbreviations of logging level names.
#define mutt_message(...)
char * message
Message to be logged.
FILE * LogFileFP
Log file handle.
static struct LogLineList LogQueue
In-memory list of log lines.
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.
char * mutt_str_dup(const char *str)
Copy a string, safely.
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
#define STAILQ_INSERT_TAIL(head, elm, field)
Log informational message.
#define STAILQ_REMOVE_HEAD(head, field)
int LogQueueMax
Maximum number of entries in the log queue.
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
log_dispatcher_t MuttLogger
The log dispatcher.
void log_file_set_version(const char *version)
Set the program's version number.
File management functions.
int log_file_set_filename(const char *file, bool verbose)
Set the filename for the log.
String manipulation functions.
int line
Line number in source file.
LogLevel
Names for the Logging Levels.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
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.
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
int log_file_set_level(enum LogLevel level, bool verbose)
Set the logging level.
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
bool log_file_running(void)
Is the log file running?
int log_file_open(bool verbose)
Start logging to a file.
int log_queue_save(FILE *fp)
Save the contents of the queue to a temporary file.
void log_queue_empty(void)
Free the contents of the queue.
#define STAILQ_FOREACH(var, head, field)
int(* log_dispatcher_t)(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Prototype for a logging function.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
#define STAILQ_HEAD_INITIALIZER(head)
time_t time
Timestamp of the message.
int LogFileLevel
Log file level.
char * LogFileVersion
Program version.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int LogQueueCount
Number of entries currently in the log queue.
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.
Time and date handling routines.
const char * file
Source file.
int log_queue_add(struct LogLine *ll)
Add a LogLine to the queue.
#define STAILQ_FIRST(head)
const char * function
C function.
char * LogFileName
Log file name.