Changeset 988 for vendor/current/lib/util/debug.h
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/util/debug.h
r746 r988 21 21 */ 22 22 23 #ifndef _DEBUG_H 24 #define _DEBUG_H 23 #ifndef _SAMBA_DEBUG_H 24 #define _SAMBA_DEBUG_H 25 26 #include <stdbool.h> 27 #include <stddef.h> 28 #include <stdarg.h> 29 #include "attr.h" 30 25 31 26 32 /* -------------------------------------------------------------------------- ** … … 37 43 #endif 38 44 39 int Debug1( const char *, ... ) PRINTF_ATTRIBUTE(1,2);45 bool dbgtext_va(const char *, va_list ap) PRINTF_ATTRIBUTE(1,0); 40 46 bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2); 41 47 bool dbghdrclass( int level, int cls, const char *location, const char *func); … … 80 86 #define DBGC_DMAPI 18 81 87 #define DBGC_REGISTRY 19 82 83 /* Always ensure this is updated when new fixed classes area added, to ensure the array in debug.c is the right size */ 84 #define DBGC_MAX_FIXED 19 88 #define DBGC_SCAVENGER 20 89 #define DBGC_DNS 21 90 #define DBGC_LDB 22 91 #define DBGC_TEVENT 23 85 92 86 93 /* So you can define DBGC_CLASS before including debug.h */ … … 160 167 unlikely(DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))) 161 168 169 #define CHECK_DEBUGLVLC( dbgc_class, level ) \ 170 ( ((level) <= MAX_DEBUG_LEVEL) && \ 171 unlikely(DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))) 172 162 173 #define DEBUGLVL( level ) \ 163 174 ( CHECK_DEBUGLVL(level) \ 164 175 && dbghdrclass( level, DBGC_CLASS, __location__, __FUNCTION__ ) ) 165 176 177 #define DEBUGLVLC( dbgc_class, level ) \ 178 ( CHECK_DEBUGLVLC( dbgc_class, level ) \ 179 && dbghdrclass( level, dbgc_class, __location__, __FUNCTION__ ) ) 166 180 167 181 #define DEBUG( level, body ) \ … … 190 204 #define DEBUGSEP(level)\ 191 205 DEBUG((level),("===============================================================\n")) 206 207 /* Prefix messages with the function name */ 208 #define DBG_PREFIX(level, body ) \ 209 (void)( ((level) <= MAX_DEBUG_LEVEL) && \ 210 unlikely(DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level)) \ 211 && (dbghdrclass(level, DBGC_CLASS, __location__, __func__ )) \ 212 && (dbgtext("%s: ", __func__)) \ 213 && (dbgtext body) ) 214 215 /* 216 * Debug levels matching RFC 3164 217 */ 218 #define DBGLVL_ERR 0 /* error conditions */ 219 #define DBGLVL_WARNING 1 /* warning conditions */ 220 #define DBGLVL_NOTICE 3 /* normal, but significant, condition */ 221 #define DBGLVL_INFO 5 /* informational message */ 222 #define DBGLVL_DEBUG 10 /* debug-level message */ 223 224 #define DBG_ERR(...) DBG_PREFIX(DBGLVL_ERR, (__VA_ARGS__)) 225 #define DBG_WARNING(...) DBG_PREFIX(DBGLVL_WARNING, (__VA_ARGS__)) 226 #define DBG_NOTICE(...) DBG_PREFIX(DBGLVL_NOTICE, (__VA_ARGS__)) 227 #define DBG_INFO(...) DBG_PREFIX(DBGLVL_INFO, (__VA_ARGS__)) 228 #define DBG_DEBUG(...) DBG_PREFIX(DBGLVL_DEBUG, (__VA_ARGS__)) 192 229 193 230 /* The following definitions come from lib/debug.c */ … … 198 235 * the command line, as the smb.conf cannot reset it back to 199 236 * file-based logging */ 200 enum debug_logtype {DEBUG_DEFAULT_STDERR = 0, DEBUG_STDOUT = 1, DEBUG_FILE = 2, DEBUG_STDERR = 3}; 237 enum debug_logtype { 238 DEBUG_DEFAULT_STDERR = 0, 239 DEBUG_DEFAULT_STDOUT = 1, 240 DEBUG_FILE = 2, 241 DEBUG_STDOUT = 3, 242 DEBUG_STDERR = 4, 243 DEBUG_CALLBACK = 5 244 }; 201 245 202 246 struct debug_settings { 203 247 size_t max_log_size; 204 int syslog;205 bool syslog_only;206 248 bool timestamp_logs; 207 249 bool debug_prefix_timestamp; … … 214 256 void setup_logging(const char *prog_name, enum debug_logtype new_logtype); 215 257 216 void debug_close_dbf(void);217 258 void gfree_debugsyms(void); 218 259 int debug_add_class(const char *classname); 219 int debug_lookup_classname(const char *classname);220 260 bool debug_parse_levels(const char *params_str); 221 261 void debug_setup_talloc_log(void); 222 262 void debug_set_logfile(const char *name); 223 void debug_set_settings(struct debug_settings *settings); 263 void debug_set_settings(struct debug_settings *settings, 264 const char *logging_param, 265 int syslog_level, bool syslog_only); 224 266 bool reopen_logs_internal( void ); 225 267 void force_check_log_size( void ); … … 228 270 void dbgflush( void ); 229 271 bool dbghdrclass(int level, int cls, const char *location, const char *func); 230 bool dbghdr(int level, const char *location, const char *func);231 272 bool debug_get_output_is_stderr(void); 273 bool debug_get_output_is_stdout(void); 232 274 void debug_schedule_reopen_logs(void); 233 275 char *debug_list_class_names_and_levels(void); 234 276 277 typedef void (*debug_callback_fn)(void *private_ptr, int level, const char *msg); 278 235 279 /** 236 log suspicious usage - print comments and backtrace 237 */ 238 _PUBLIC_ void log_suspicious_usage(const char *from, const char *info); 239 240 /** 241 print suspicious usage - print comments and backtrace 242 */ 243 _PUBLIC_ void print_suspicious_usage(const char* from, const char* info); 244 _PUBLIC_ uint32_t get_task_id(void); 245 _PUBLIC_ void log_task_id(void); 246 247 /* the debug operations structure - contains function pointers to 248 various debug implementations of each operation */ 249 struct debug_ops { 250 /* function to log (using DEBUG) suspicious usage of data structure */ 251 void (*log_suspicious_usage)(const char* from, const char* info); 252 253 /* function to log (using printf) suspicious usage of data structure. 254 * To be used in circumstances when using DEBUG would cause loop. */ 255 void (*print_suspicious_usage)(const char* from, const char* info); 256 257 /* function to return process/thread id */ 258 uint32_t (*get_task_id)(void); 259 260 /* function to log process/thread id */ 261 void (*log_task_id)(int fd); 262 }; 263 264 /** 265 register a set of debug handlers. 266 */ 267 _PUBLIC_ void register_debug_handlers(const char *name, struct debug_ops *ops); 268 269 #endif 280 Set a callback for all debug messages. Use in dlz_bind9 to push output to the bind logs 281 */ 282 void debug_set_callback(void *private_ptr, debug_callback_fn fn); 283 284 #endif /* _SAMBA_DEBUG_H */
Note:
See TracChangeset
for help on using the changeset viewer.