#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include "mutt/lib.h"
Go to the source code of this file.
|
int | log_disp_curses (time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...) |
| Display a log line in the message line - Implements log_dispatcher_t. More...
|
|
void | mutt_log_prep (void) |
| Prepare to log. More...
|
|
int | mutt_log_start (void) |
| Enable file logging. More...
|
|
void | mutt_log_stop (void) |
| Close the log file. More...
|
|
int | mutt_log_set_level (enum LogLevel level, bool verbose) |
| Change the logging level. More...
|
|
int | mutt_log_set_file (const char *file, bool verbose) |
| Change the logging file. More...
|
|
int | mutt_log_observer (struct NotifyCallback *nc) |
| Listen for config changes affecting the log file - Implements observer_t. More...
|
|
int | level_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err) |
| Validate the "debug_level" config variable - Implements ConfigDef::validator() More...
|
|
void | mutt_clear_error (void) |
| Clear the message line (bottom line of screen) More...
|
|
NeoMutt Logging
- Authors
-
- Copyright
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file mutt_logging.h.
◆ log_disp_curses()
int log_disp_curses |
( |
time_t |
stamp, |
|
|
const char * |
file, |
|
|
int |
line, |
|
|
const char * |
function, |
|
|
enum LogLevel |
level, |
|
|
|
... |
|
) |
| |
Display a log line in the message line - Implements log_dispatcher_t.
Definition at line 127 of file mutt_logging.c.
137 const char *fmt = va_arg(ap,
const char *);
138 int ret = vsnprintf(buf,
sizeof(buf), fmt, ap);
143 char *buf2 = buf + ret;
144 int len =
sizeof(buf) - ret;
145 const char *p = strerror(errno);
147 p =
_(
"unknown error");
149 ret += snprintf(buf2, len,
": %s (errno = %d)", p, errno);
152 const bool dupe = (strcmp(buf,
ErrorBuf) == 0);
156 log_disp_file(stamp, file, line,
function, level,
"%s", buf);
◆ mutt_log_prep()
void mutt_log_prep |
( |
void |
| ) |
|
Prepare to log.
Definition at line 213 of file mutt_logging.c.
216 snprintf(ver,
sizeof(ver),
"-%s%s", PACKAGE_VERSION,
GitVer);
◆ mutt_log_start()
int mutt_log_start |
( |
void |
| ) |
|
Enable file logging.
- Return values
-
0 | Success, or already running |
-1 | Failed to start |
This also handles file rotation.
Definition at line 282 of file mutt_logging.c.
◆ mutt_log_stop()
void mutt_log_stop |
( |
void |
| ) |
|
◆ mutt_log_set_level()
int mutt_log_set_level |
( |
enum LogLevel |
level, |
|
|
bool |
verbose |
|
) |
| |
Change the logging level.
- Parameters
-
level | Logging level |
verbose | If true, then log the event |
- Return values
-
0 | Success |
-1 | Error, level is out of range |
Definition at line 263 of file mutt_logging.c.
◆ mutt_log_set_file()
int mutt_log_set_file |
( |
const char * |
file, |
|
|
bool |
verbose |
|
) |
| |
Change the logging file.
- Parameters
-
file | Name to use |
verbose | If true, then log the event |
- Return values
-
0 | Success, file opened |
-1 | Error, see errno |
Close the old log, rotate the new logs and open the new log.
Definition at line 238 of file mutt_logging.c.
◆ mutt_log_observer()
◆ level_validator()
◆ mutt_clear_error()
void mutt_clear_error |
( |
void |
| ) |
|
Clear the message line (bottom line of screen)
Definition at line 113 of file mutt_logging.c.
◆ C_DebugLevel
Config: Logging level for debug logs.
Definition at line 48 of file mutt_logging.c.
◆ C_DebugFile
void mutt_beep(bool force)
Irritate the user.
void log_file_set_version(const char *version)
Set the program's version number.
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
char * CurrentFile
The previous log file name.
struct MuttWindow * MessageWindow
Message Window, ":set", etc.
static const char * rotate_logs(const char *file, int count)
Rotate a set of numbered files.
@ MT_COLOR_ERROR
Error message.
uint64_t mutt_date_epoch_ms(void)
Return the number of milliseconds since the Unix epoch.
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
@ MT_COLOR_WARNING
Warning messages.
#define CSR_SUCCESS
Action completed successfully.
@ LL_PERROR
Log perror (using errno)
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
int mutt_log_set_file(const char *file, bool verbose)
Change the logging file.
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
@ MT_COLOR_NORMAL
Plain text.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
uint64_t LastError
Time of the last error message (in milliseconds since the Unix epoch)
@ MT_COLOR_MESSAGE
Informational message.
@ JUSTIFY_LEFT
Left justify the text.
const char * name
User-visible name.
WHERE char ErrorBuf[256]
Copy of the last error message.
@ LL_MESSAGE
Log informational message.
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, enum FormatJustify justify, char pad_char, const char *s, size_t n, bool arboreal)
Format a string, like snprintf()
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
int mutt_log_set_level(enum LogLevel level, bool verbose)
Change the logging level.
int log_file_set_filename(const char *file, bool verbose)
Set the filename for the log.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
void * event_data
Data from notify_send()
struct WindowState state
Current state of the Window.
bool log_file_running(void)
Is the log file running?
short C_DebugLevel
Config: Logging level for debug logs.
char * C_DebugFile
Config: File to save debug logs.
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.
int log_file_set_level(enum LogLevel level, bool verbose)
Set the logging level.
const char * name
Name of config item that changed.
Container for Accounts, Notifications.
WHERE bool OptMsgErr
(pseudo) used by mutt_error/mutt_message
void log_file_close(bool verbose)
Close the log file.
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
void mutt_refresh(void)
Force a refresh of the screen.
struct ConfigSubset * sub
Inherited config items.
WHERE bool ErrorBufMessage
true if the last message was an error
WHERE bool OptKeepQuiet
(pseudo) shut up the message and refresh functions while we are executing an external program
int mutt_window_mvaddstr(struct MuttWindow *win, int col, int row, const char *str)
Move the cursor and write a fixed string to a Window.
#define CSR_ERR_INVALID
Value hasn't been set.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
static void error_pause(void)
Wait for an error message to be read.
const int NumOfLogs
How many log files to rotate.
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.