80 static char buf[23] = { 0 };
81 static time_t last = 0;
105 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"
246int log_disp_file(time_t stamp,
const char *file,
int line,
const char *function,
247 enum LogLevel level,
const char *format, ...)
256 function =
"UNKNOWN";
261 va_start(ap, format);
267 fprintf(
LogFileFP,
": %s\n", strerror(err));
372 char buf[32] = { 0 };
405 va_start(ap, format);
406 int rc = vsnprintf(buf,
sizeof(buf), format, ap);
411 if ((rc >= 0) && (rc <
sizeof(buf)))
412 rc += snprintf(buf + rc,
sizeof(buf) - rc,
": %s", strerror(err));
447 va_start(ap, format);
448 int rc = vsnprintf(buf,
sizeof(buf), format, ap);
459 bool tty = (isatty(fileno(fp)) == 1);
479 rc += fprintf(fp,
"\033[1;%dm", color);
484 rc += fprintf(fp,
": %s", strerror(err));
487 rc += fprintf(fp,
"\033[0m");
489 rc += fprintf(fp,
"\n");
503 int line,
const char *func)
505 while (str && (str[0] !=
'\0'))
507 const char *end = strchr(str,
'\n');
Time and date handling routines.
const char * LevelAbbr
Abbreviations of logging level names.
File management functions.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
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_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.
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.
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.
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.
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.
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.