Add copyright notice
[forms.git] / F / F_Log.H
blobe9e130719b98ebbdcbb7b55e71c17e76d4b5062d
2  /*
3   *   Copyright (C) 2007, Harbour, All rights reserved.
4   */
6 #ifndef _F_LOG_H_
7 #define _F_LOG_H_
9 #include <F_Types.H>
10 #include <sys/types.h>
11 #include <signal.h>
12 #include <string>
14 namespace F {
16 // ÅÓÌÉ true, ÄÏ ÐÒÏÉÚÏÛÌÁ ÏÛÉÂËÁ
17 extern bool sigsegv_;
19 /*! The simple log implemetation
20  */
22 #define DEFAULT_LOG_LEVEL INFO_LEVEL
24  void log_init(void);
25  void log_file(const char *f);
26  void log_final(void);
28  void log_level(log_level_t level);
29  void log_level(const char *level);
30  void log_date_format(std::string &format);
31  void log_date_format(const char *format);
32  void log_msgbuf_size(unsigned int size);
33  void log_prefix(const char *prefix);
35  void log_(const char *location, const char *buf);
36  void log_(const char *location, log_level_t level, const char *buf);
37  void log(const char *location, const char *fmt, ...);
38  void log(const char *location, log_level_t level, const char *fmt, ...);
40  void shutdown(int retval) __attribute__((noreturn));
42 #define dlog(x...)  F::log(__PRETTY_FUNCTION__, INFO_LEVEL, ##x)
44 #ifdef DEBUG_VERSION
45 #define debug(x...)  F::log(__PRETTY_FUNCTION__, DEBUG_LEVEL, ##x)
46 #define bug() do { sigsegv_ = true; F::log(__PRETTY_FUNCTION__, FATAL_LEVEL, \
47                     "*** Bug detected at %s:%d.", __FILE__, __LINE__); \
48                     F::shutdown(-1); } while(0)
49 #define trace_bug() do { sigsegv_ = true; F::log(__PRETTY_FUNCTION__, FATAL_LEVEL, \
50                     "*** Bug detected at %s:%d, tracing:", __FILE__, __LINE__); \
51                     kill(0, F_TRACE_SIGNAL); \
52                     F::shutdown(-1); } while(0)
53 #define exit_on_unimplemented(feature) do { sigsegv_ = true; F::log(__PRETTY_FUNCTION__, FATAL_LEVEL, \
54                     "Sorry, feature \'%s\' at %s:%d. in not implemented yet.", feature, __FILE__, __LINE__); \
55                     F::shutdown(-1); } while(0)
56 #define unimplemented(feature) do { F::log(__PRETTY_FUNCTION__, WARN_LEVEL, \
57                     "Sorry, feature \'%s\' at %s:%d. in not implemented yet.", feature, __FILE__, __LINE__); \
58                     } while(0)
59 #define bug_on(condition) do { if (condition) bug(); } while(0)
60 #define trace_bug_on(condition) do { if (condition) bug(); } while(0)
61 #else
62 #define debug(x...) do { } while (0)
63 #define bug() do { } while (0)
64 #define trace_bug() do { } while (0)
65 #define unimplemented(x) do { } while (0)
66 #define exit_on_unimplemented(x) do { } while (0)
67 #define bug_on(condition) do { } while (0)
68 #define trace_bug_on(condition) do { } while (0)
69 #endif
71 } // namespace F
73 #endif