5 Useful as the main logger of a program
9 #define FLOG_NOTHING 0x00
10 #define FLOG_NONE FLOG_NOTHING
13 #define FLOG_CRITICAL 0x01
14 #define FLOG_CRIT FLOG_CRITICAL
17 #define FLOG_ERROR 0x02
18 #define FLOG_ERR FLOG_ERROR
21 #define FLOG_WARNING 0x04
22 #define FLOG_WARN FLOG_WARNING
23 #define FLOG_ALERT FLOG_WARNING
26 #define FLOG_NOTE 0x08
27 #define FLOG_NOTIFY FLOG_NOTE
28 #define FLOG_IMP FLOG_NOTE
29 #define FLOG_IMPORTANT FLOG_NOTE
32 #define FLOG_INFO 0x10
33 #define FLOG_INFORMATION FLOG_INFO
34 #define FLOG_MSG FLOG_INFO
35 #define FLOG_MESSAGE FLOG_INFO
37 //! Info in verbose mode
38 #define FLOG_VERBOSE 0x20
39 #define FLOG_VINFO FLOG_VERBOSE
42 #define FLOG_DEBUG 0x40
44 //! Debug info for flog itself
45 #define FLOG_FLOG_DEBUG 0x80
47 //! Bitmask to show only errors
48 #define FLOG_SHOW_ONLY_ERRORS FLOG_CRIT | FLOG_ERR
49 #define FLOG_SHOW_ERRORS_AND_WARNINGS FLOG_CRIT | FLOG_ERR | FLOG_WARN
50 #define FLOG_SHOW_IMPORTANT_NOTES FLOG_CRIT | FLOG_ERR | FLOG_WARN | FLOG_NOTE
51 #define FLOG_SHOW_INFO FLOG_CRIT | FLOG_ERR | FLOG_WARN | FLOG_NOTE | FLOG_INFO
52 #define FLOG_SHOW_VERBOSE_INFO FLOG_CRIT | FLOG_ERR | FLOG_WARN | FLOG_NOTE | FLOG_INFO | FLOG_VINFO
53 #define FLOG_SHOW_ALL FLOG_CRIT | FLOG_ERR | FLOG_WARN | FLOG_NOTE | FLOG_INFO | FLOG_VINFO | FLOG_DEBUG
54 #define FLOG_SHOW_FLOG_DEBUG FLOG_CRIT | FLOG_ERR | FLOG_WARN | FLOG_NOTE | FLOG_INFO | FLOG_VINFO | FLOG_DEBUG | FLOG_FLOG_DEBUG
56 //#define FLOG_DEBUGGING_ON
58 #ifdef FLOG_DEBUGGING_ON
59 #define flog_dprint(type, subsystem, text) flog_print (type, subsystem, text)
60 #define flog_dprintf(type, subsystem, ...) flog_printf (type, subsystem, __VA_ARGS__)
62 #define flog_dprint(type, subsystem, text) 0
63 #define flog_dprintf(type, subsystem, ...) 0
66 //! Contains flog main settings
67 struct struct_flog_opt
69 //! @todo implement this
70 char subsystem_prepend
[512]; //!< string to prepend to subsystem
72 //! @todo implement this
73 int logbuffer_lines
; //!< amount of log buffer lines
75 int accepted_messages_stderr
; //!< bitmask of which messages to write to stderr
77 int accepted_messages_stdout
; //!< bitmask of which messages to write to stdout
80 int accepted_messages_file
; //!< bitmask of which messages to write to file
82 char logfile
[261]; //!< log filename
84 //! @todo implement this
85 int buffered_write
; //!< if set buffers writes in memory
87 int write_error
; //!< if set a write error has occured and no more writes will be done until unset
90 //! Initialise flog lib.
93 @param log_name name of log, appended to messages
94 @param am_stderr accepted messages for stderr
95 @param am_stdout accepted messages for stdout
96 @param am_file accepted messages for file output
97 @param filename_log name of logfile
98 @return 0 = no errors occured
100 int flog_init(const char *log_name
,int am_stderr
,int am_stdout
,int am_file
,const char *filename_log
);
102 //! output an flog message
104 @param type use one of the FLOG_* defines
105 @param subsystem which part of the program is outputing this message (use __func__ typically)
106 @param text message text
107 @return 0 = no errors occured
109 int flog_print(int type
,const char *subsystem
,const char *text
);
111 //! formatted message output (calls flog_printf())
113 @param type use one of the FLOG_* defines
114 @param subsystem which part of the program is outputing this message (use __func__ typically)
115 @param text_format formatted message text
116 @return 0 = no errors occured
118 int flog_printf(int type
,const char *subsystem
,const char *text_format
, ...);
120 //! tests outputting all kinds of text messages
121 void flog_test(void);
123 const char * get_timestamp(void);
125 const char * get_msg_type(int type
);