3 * Copyright (C) 2007, Harbour, All rights reserved.
10 #include <sys/types.h>
17 // ÅÓÌÉ true, ÄÏ ÐÒÏÉÚÏÛÌÁ ÏÛÉÂËÁ
20 /*! The simple log implemetation
23 #define DEFAULT_LOG_LEVEL INFO_LEVEL
25 void log_init(const char *);
26 void log_file(const char *f);
29 void log_level(log_level_t level);
30 void log_level(const char *level);
31 void log_date_format(std::string &format);
32 void log_date_format(const char *format);
33 void log_msgbuf_size(unsigned int size);
34 void log_prefix(const char *prefix);
36 void log_(const char *location, const char *buf);
37 void log_(const char *location, log_level_t level, const char *buf);
38 void log(const char *location, const char *fmt, ...);
39 void log(const char *location, log_level_t level, const char *fmt, ...);
41 void shutdown(int retval) __attribute__((noreturn));
43 #define dlog(x...) F::log(__PRETTY_FUNCTION__, INFO_LEVEL, ##x)
47 #define F_STRINGIFY(x) F_STRINGIFY_ARG(x)
48 #define F_STRINGIFY_ARG(x) (#x)
50 #define debug(x...) do { std::string _prefix = __FILE__; \
52 _prefix += F_STRINGIFY(__LINE__); \
54 _prefix += __PRETTY_FUNCTION__; \
55 F::log(_prefix.c_str(), DEBUG_LEVEL, ##x); } while(0)
57 #define bug() do { sigsegv_ = true; F::log(__PRETTY_FUNCTION__, FATAL_LEVEL, \
58 "*** Bug detected at %s:%d.", __FILE__, __LINE__); \
59 F::shutdown(-1); } while(0)
60 #define trace_bug() do { sigsegv_ = true; F::log(__PRETTY_FUNCTION__, FATAL_LEVEL, \
61 "*** Bug detected at %s:%d, tracing:", __FILE__, __LINE__); \
62 kill(0, F_TRACE_SIGNAL); \
63 F::shutdown(-1); } while(0)
64 #define exit_on_unimplemented(feature) do { sigsegv_ = true; F::log(__PRETTY_FUNCTION__, FATAL_LEVEL, \
65 "Sorry, feature \'%s\' at %s:%d. in not implemented yet.", feature, __FILE__, __LINE__); \
66 F::shutdown(-1); } while(0)
67 #define unimplemented(feature) do { F::log(__PRETTY_FUNCTION__, WARN_LEVEL, \
68 "Sorry, feature \'%s\' at %s:%d. in not implemented yet.", feature, __FILE__, __LINE__); \
70 #define bug_on(condition) do { if (condition) bug(); } while(0)
71 #define trace_bug_on(condition) do { if (condition) bug(); } while(0)
73 #define debug(x...) do { } while (0)
74 #define bug() do { } while (0)
75 #define trace_bug() do { } while (0)
76 #define unimplemented(x) do { } while (0)
77 #define exit_on_unimplemented(x) do { } while (0)
78 #define bug_on(condition) do { } while (0)
79 #define trace_bug_on(condition) do { } while (0)