Logging Dispatcher. More...
Go to the source code of this file.
Data Structures | |
struct | LogLine |
A Log line. More... | |
Macros | |
#define | mutt_debug(LEVEL, ...) MuttLogger(0, __FILE__, __LINE__, __func__, LEVEL, __VA_ARGS__) |
#define | mutt_warning(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_WARNING, __VA_ARGS__) |
#define | mutt_message(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_MESSAGE, __VA_ARGS__) |
#define | mutt_error(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_ERROR, __VA_ARGS__) |
#define | mutt_perror(...) MuttLogger(0, __FILE__, __LINE__, __func__, LL_PERROR, __VA_ARGS__) |
Typedefs | |
typedef int(* | log_dispatcher_t) (time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...) |
Enumerations | |
enum | LogLevel { LL_PERROR = -3 , LL_ERROR = -2 , LL_WARNING = -1 , LL_MESSAGE = 0 , LL_DEBUG1 = 1 , LL_DEBUG2 = 2 , LL_DEBUG3 = 3 , LL_DEBUG4 = 4 , LL_DEBUG5 = 5 , LL_NOTIFY = 6 , LL_MAX } |
Names for the Logging Levels. More... | |
Functions | |
STAILQ_HEAD (LogLineList, LogLine) | |
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 -. More... | |
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 -. More... | |
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 -. More... | |
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 -. More... | |
int | log_queue_add (struct LogLine *ll) |
Add a LogLine to the queue. More... | |
void | log_queue_empty (void) |
Free the contents of the queue. More... | |
void | log_queue_flush (log_dispatcher_t disp) |
Replay the log queue. More... | |
int | log_queue_save (FILE *fp) |
Save the contents of the queue to a temporary file. More... | |
void | log_queue_set_max_size (int size) |
Set a upper limit for the queue length. More... | |
void | log_file_close (bool verbose) |
Close the log file. More... | |
int | log_file_open (bool verbose) |
Start logging to a file. More... | |
bool | log_file_running (void) |
Is the log file running? More... | |
int | log_file_set_filename (const char *file, bool verbose) |
Set the filename for the log. More... | |
int | log_file_set_level (enum LogLevel level, bool verbose) |
Set the logging level. More... | |
void | log_file_set_version (const char *version) |
Set the program's version number. More... | |
Variables | |
log_dispatcher_t | MuttLogger |
The log dispatcher -. More... | |
Logging Dispatcher.
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 logging.h.
typedef int(* log_dispatcher_t) (time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...) |
enum LogLevel |
Names for the Logging Levels.
STAILQ_HEAD | ( | LogLineList | , |
LogLine | |||
) |
int log_queue_add | ( | struct LogLine * | ll | ) |
Add a LogLine to the queue.
ll | LogLine to add |
num | Entries in the queue |
If LogQueueMax is non-zero, the queue will be limited to this many items.
Definition at line 285 of file logging.c.
void log_queue_empty | ( | void | ) |
Free the contents of the queue.
Free any log lines in the queue.
Definition at line 324 of file logging.c.
void log_queue_flush | ( | log_dispatcher_t | disp | ) |
Replay the log queue.
disp | Log dispatcher - Implements log_dispatcher_t |
Pass all of the log entries in the queue to the log dispatcher provided. The queue will be emptied afterwards.
Definition at line 346 of file logging.c.
int log_queue_save | ( | FILE * | fp | ) |
Save the contents of the queue to a temporary file.
fp | Open file handle |
num | Lines written to the file |
The queue is written to a temporary file. The format is:
[HH:MM:SS]<LEVEL> FORMATTED-MESSAGE
Definition at line 367 of file logging.c.
void log_queue_set_max_size | ( | int | size | ) |
void log_file_close | ( | bool | verbose | ) |
Close the log file.
verbose | If true, then log the event |
Definition at line 98 of file logging.c.
int log_file_open | ( | bool | verbose | ) |
Start logging to a file.
verbose | If true, then log the event |
0 | Success |
-1 | Error, see errno |
Before opening a log file, call log_file_set_version(), log_file_set_level() and log_file_set_filename().
Definition at line 119 of file logging.c.
bool log_file_running | ( | void | ) |
int log_file_set_filename | ( | const char * | file, |
bool | verbose | ||
) |
Set the filename for the log.
file | Name to use |
verbose | If true, then log the event |
0 | Success, file opened |
-1 | Error, see errno |
Definition at line 149 of file logging.c.
int log_file_set_level | ( | enum LogLevel | level, |
bool | verbose | ||
) |
Set the logging level.
level | Logging level |
verbose | If true, then log the event |
0 | Success |
-1 | Error, level is out of range |
The level should be: LL_MESSAGE <= level < LL_MAX.
Definition at line 175 of file logging.c.
void log_file_set_version | ( | const char * | version | ) |