79 static char buf[23] = { 0 };
80 static time_t last = 0;
104 fprintf(
LogFileFP,
"# vim: syntax=neomuttlog\n");
205 " Logging at this level can reveal personal information.\n"
206 " Review the log carefully before posting in bug reports.\n"
245int log_disp_file(time_t stamp,
const char *file,
int line,
const char *function,
246 enum LogLevel level,
const char *format, ...)
255 function =
"UNKNOWN";
260 va_start(ap, format);
266 fprintf(
LogFileFP,
": %s\n", strerror(err));
371 char buf[32] = { 0 };
404 va_start(ap, format);
405 int rc = vsnprintf(buf,
sizeof(buf), format, ap);
410 if ((rc >= 0) && (rc <
sizeof(buf)))
411 rc += snprintf(buf + rc,
sizeof(buf) - rc,
": %s", strerror(err));
446 va_start(ap, format);
447 int rc = vsnprintf(buf,
sizeof(buf), format, ap);
458 bool tty = (isatty(fileno(fp)) == 1);
478 rc += fprintf(fp,
"\033[1;%dm", colour);
483 rc += fprintf(fp,
": %s", strerror(err));
486 rc += fprintf(fp,
"\033[0m");
488 rc += fprintf(fp,
"\n");
Time and date handling routines.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
File management functions.
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 -.
int log_disp_null(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...)
Discard log lines - Implements log_dispatcher_t -.
int log_disp_file(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...)
Save a log line to a file - Implements log_dispatcher_t -.
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 -.
log_dispatcher_t MuttLogger
The log dispatcher -.
#define mutt_message(...)
int(* log_dispatcher_t)(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...) __attribute__((__format__(__printf__
LogLevel
Names for the Logging Levels.
@ LL_PERROR
Log perror (using errno)
@ LL_DEBUG5
Log at debug level 5.
@ LL_MESSAGE
Log informational message.
@ LL_DEBUG1
Log at debug level 1.
#define LOG_LINE_MAX_LEN
Log lines longer than this will be truncated.
int log_file_open(bool verbose)
Start logging to a file.
static FILE * LogFileFP
Log file handle.
void log_queue_empty(void)
Free the contents of the queue.
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
int log_file_set_level(enum LogLevel level, bool verbose)
Set the logging level.
static struct LogLineList LogQueue
In-memory list of log lines.
bool log_file_running(void)
Is the log file running?
static char * LogFileVersion
Program version.
static int LogQueueMax
Maximum number of entries in the log queue.
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
static const char * LevelAbbr
Abbreviations of logging level names.
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
static int LogQueueCount
Number of entries currently in the log queue.
static int LogFileLevel
Log file level.
int log_queue_save(FILE *fp)
Save the contents of the queue to a temporary file.
static char * LogFileName
Log file name.
void log_file_close(bool verbose)
Close the log file.
int log_file_set_filename(const char *file, bool verbose)
Set the filename for the log.
int log_queue_add(struct LogLine *ll)
Add a LogLine to the queue.
void log_file_set_version(const char *version)
Set the program's version number.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Memory management wrappers.
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
#define STAILQ_REMOVE_HEAD(head, field)
#define STAILQ_REMOVE(head, elm, type, field)
#define STAILQ_HEAD_INITIALIZER(head)
#define STAILQ_FIRST(head)
#define STAILQ_FOREACH(var, head, field)
#define STAILQ_INSERT_TAIL(head, elm, field)
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
String manipulation functions.
const char * file
Source file.
char * message
Message to be logged.
const char * function
C function.
int line
Line number in source file.
enum LogLevel level
Log level, e.g. LL_DEBUG1.
time_t time
Timestamp of the message.