~ubuntu-branches/ubuntu/precise/autofs5/precise

« back to all changes in this revision

Viewing changes to .pc/autofs-5.0.5-add-dump-maps-option.patch/include/log.h

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-03 14:35:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110703143546-nej26krjij0rf792
Tags: 5.0.6-0ubuntu1
* New upstream release:
  - Dropped upstream patches 
  - Refreshed debian/patches/17ld.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ----------------------------------------------------------------------- *
2
 
 *
3
 
 *  log.c - applcation logging declarations.
4
 
 *
5
 
 *   Copyright 2004 Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
6
 
 *                               - All Rights Reserved
7
 
 *   Copyright 2005 Ian Kent <raven@themaw.net> - All Rights Reserved
8
 
 *
9
 
 *   This program is free software; you can redistribute it and/or modify
10
 
 *   it under the terms of the GNU General Public License as published by
11
 
 *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
12
 
 *   USA; either version 2 of the License, or (at your option) any later
13
 
 *   version; incorporated herein by reference.
14
 
 *
15
 
 * ----------------------------------------------------------------------- */
16
 
 
17
 
#ifndef LOG_H
18
 
#define LOG_H
19
 
 
20
 
/* Define logging functions */
21
 
 
22
 
#define LOGOPT_NONE     0x0000
23
 
#define LOGOPT_ERROR    0x0000
24
 
#define LOGOPT_DEBUG    0x0001
25
 
#define LOGOPT_VERBOSE  0x0002
26
 
#define LOGOPT_ANY      (LOGOPT_DEBUG | LOGOPT_VERBOSE)
27
 
 
28
 
struct autofs_point;
29
 
 
30
 
extern void set_log_norm(void);
31
 
extern void set_log_verbose(void);
32
 
extern void set_log_debug(void);
33
 
extern void set_log_norm_ap(struct autofs_point *ap);
34
 
extern void set_log_verbose_ap(struct autofs_point *ap);
35
 
extern void set_log_debug_ap(struct autofs_point *ap);
36
 
extern void set_mnt_logging(unsigned global_logopt);
37
 
 
38
 
extern void log_to_syslog(void);
39
 
extern void log_to_stderr(void);
40
 
 
41
 
extern void log_info(unsigned int, const char* msg, ...);
42
 
extern void log_notice(unsigned int, const char* msg, ...);
43
 
extern void log_warn(unsigned int, const char* msg, ...);
44
 
extern void log_error(unsigned, const char* msg, ...);
45
 
extern void log_crit(unsigned, const char* msg, ...);
46
 
extern void log_debug(unsigned int, const char* msg, ...);
47
 
extern void logmsg(const char* msg, ...);
48
 
 
49
 
#define debug(opt, msg, args...)        \
50
 
        do { log_debug(opt, "%s: " msg,  __FUNCTION__, ##args); } while (0)
51
 
 
52
 
#define info(opt, msg, args...)         \
53
 
        do { log_info(opt, msg,  ##args); } while (0)
54
 
 
55
 
#define notice(opt, msg, args...)       \
56
 
        do { log_notice(opt, msg, ##args); } while (0)
57
 
 
58
 
#define warn(opt, msg, args...)         \
59
 
        do { log_warn(opt, msg, ##args); } while (0)
60
 
 
61
 
#define error(opt, msg, args...)        \
62
 
        do { log_error(opt, "%s: " msg,  __FUNCTION__, ##args); } while (0)
63
 
 
64
 
#define crit(opt, msg, args...) \
65
 
        do { log_crit(opt, "%s: " msg,  __FUNCTION__, ##args); } while (0)
66
 
 
67
 
#define logerr(msg, args...)    \
68
 
        do { logmsg("%s:%d: " msg, __FUNCTION__, __LINE__, ##args); } while (0)
69
 
 
70
 
#define fatal(status)                                               \
71
 
        do {                                                        \
72
 
                if (status == EDEADLK) {                            \
73
 
                        logmsg("deadlock detected "                 \
74
 
                                 "at line %d in %s, dumping core.", \
75
 
                                  __LINE__, __FILE__);              \
76
 
                        dump_core();                                \
77
 
                }                                                   \
78
 
                logmsg("unexpected pthreads error: %d at %d "       \
79
 
                         "in %s", status, __LINE__, __FILE__);      \
80
 
                abort();                                            \
81
 
        } while(0)
82
 
 
83
 
#ifndef NDEBUG
84
 
#define assert(x)                                                       \
85
 
do {                                                                    \
86
 
        if (!(x)) {                                                     \
87
 
                logmsg(__FILE__                                 \
88
 
                         ":%d: assertion failed: " #x, __LINE__);       \
89
 
        }                                                               \
90
 
} while(0)
91
 
#else
92
 
#define assert(x)       do { } while(0)
93
 
#endif
94
 
 
95
 
#endif
96