/camera/imageviewer

To get this branch, use:
bzr branch http://darksoft.org/webbzr/camera/imageviewer

« back to all changes in this revision

Viewing changes to cameralink/ds_log.h

  • Committer: Suren A. Chilingaryan
  • Date: 2011-02-13 01:34:55 UTC
  • Revision ID: csa@dside.dyndns.org-20110213013455-7999955h7v4uf9m8
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _DS_LOG_H
 
2
#define _DS_LOG_H
 
3
 
 
4
#include <glib.h>
 
5
 
 
6
typedef void (*DSExceptionHandler)(int err, const gchar *msg);
 
7
 
 
8
 
 
9
#define ds_log(log_levels, module, err, ...) \
 
10
    _ds_log_message(0, G_LOG_DOMAIN, log_levels,  (log_levels&DS_LOG_FATAL_MESSAGE)?__FILE__:NULL, __func__, __LINE__, NULL, module, NULL, NULL, err, __VA_ARGS__)
 
11
 
 
12
#define ds_conditional_log(condition, log_levels, module, err, ...) \
 
13
    _ds_log_message(condition, G_LOG_DOMAIN, log_levels,  (log_levels&DS_LOG_FATAL_MESSAGE)?__FILE__:NULL, __func__, __LINE__, NULL, module, NULL, NULL, err, __VA_ARGS__)
 
14
 
 
15
#define ds_custom_log(condition, log_levels, module, prefix, err, ...) \
 
16
    _ds_log_message(condition, G_LOG_DOMAIN, log_levels, (log_levels&DS_LOG_FATAL_MESSAGE)?__FILE__:NULL, __func__, __LINE__, NULL, module, NULL, prefix, err, __VA_ARGS__)
 
17
 
 
18
 
 
19
#define ds_debug(...) ds_log(G_LOG_LEVEL_DEBUG, NULL, 0, __VA_ARGS__)
 
20
#define ds_info(...) ds_log(G_LOG_LEVEL_INFO, NULL, 0, __VA_ARGS__)
 
21
#define ds_warning(...) ds_log(G_LOG_LEVEL_WARNING, NULL, 0, __VA_ARGS__)
 
22
#define ds_error(...) ds_log(G_LOG_LEVEL_CRITICAL, NULL, 0, __VA_ARGS__)
 
23
#define ds_fail(...) ds_log((GLogLevelFlags)(G_LOG_LEVEL_ERROR|DS_LOG_FATAL_MESSAGE), NULL, 0, __VA_ARGS__)
 
24
 
 
25
 
 
26
#define ds_exception(cond, err, ...) ds_conditional_log(cond, G_LOG_LEVEL_CRITICAL, NULL, err, __VA_ARGS__)
 
27
#define ds_exception_reterr(cond, err, ...) if (ds_exception(cond, err, __VA_ARGS__)) return err
 
28
#define ds_exception_retnull(cond, err, ...) if (ds_exception(cond, err, __VA_ARGS__)) return NULL
 
29
 
 
30
#ifdef __cplusplus
 
31
extern "C" {
 
32
#endif
 
33
 
 
34
/**
 
35
  * Pushes message into the glib log file, this is maximal function which is
 
36
  * expected to be called from various define macroses
 
37
  *
 
38
  * @param condition is message is shown only if condition is false
 
39
  * @param log_domain is the log domain, usually G_LOG_DOMAIN
 
40
  * @param log_level is the log level, either from GLogLevelFlags or a user-defined level, may indicate fatality
 
41
  * @param file is source file where the event have occured
 
42
  * @param func is function name where the event have occured
 
43
  * @param line is source line where the event have occured
 
44
  * @param service is the type of service which haev produced the event
 
45
  * @param module is the type of module which have produced the event
 
46
  * @param ptr is the object which have produced the event
 
47
  * @param prefix is a message enclosing err and message (%s replaced with message and %iud... with error code)
 
48
  * @param err is error code (0 - not an error, -1 - from errno)
 
49
  * @param format is the message format. See the printf() documentation
 
50
  */
 
51
int _ds_log_message(int condition, const gchar *log_domain, GLogLevelFlags log_levels, const char *file, const char *func, int line, const gchar *service, const gchar *module, void *ptr, gchar *prefix, int err, gchar *format, ...);
 
52
 
 
53
 
 
54
#define ds_log_message(condition, log_domain, log_levels, service, module, addr, prefix, err, ...) \
 
55
    _ds_log_message(condition, log_domain, log_levels, __FILE__, __func__, __LINE__, service, module, addr, prefix, err, __VA_ARGS__)
 
56
 
 
57
/** Terminate application after printing message */
 
58
#define DS_LOG_FATAL_MESSAGE G_LOG_FLAG_FATAL
 
59
/** Free memory occupied by message if prefix is undefined or prefix otherwise */
 
60
#define DS_LOG_CLEAN_MESSAGE G_LOG_FLAG_RECURSION
 
61
/** Mask for selecting all levels */
 
62
#define DS_LOG_LEVEL_MASK G_LOG_LEVEL_MASK
 
63
 
 
64
/** Set required logger output and logging details (for all domains)
 
65
  * 
 
66
  * @param log_level - maximal log detail
 
67
  * @param sink - currently unsupported
 
68
  */
 
69
void ds_configure_logger(GLogLevelFlags log_level, const char *sink);
 
70
 
 
71
/** Set required logging details (for all domains)
 
72
  * 
 
73
  * @param log_level - maximal log detail
 
74
  */
 
75
void ds_log_set_level(GLogLevelFlags log_level);
 
76
 
 
77
/** Switches on logging message timestmaps */
 
78
void ds_log_enable_timestamps();
 
79
 
 
80
/** Switches on logging threading information */
 
81
void ds_log_enable_threads();
 
82
 
 
83
/** Enables specific exception handler */
 
84
void ds_log_configure_exception_handler(GLogLevelFlags log_level, DSExceptionHandler handler, int log_exception_message);
 
85
 
 
86
# ifdef __cplusplus
 
87
}
 
88
# endif
 
89
 
 
90
#endif /* _DS_LOG_H */