source: trunk/drmaa_utils/drmaa_utils/logging.h @ 1

Revision 1, 3.0 KB checked in by mmamonski, 13 years ago (diff)

Torque/PBS DRMAA initial commit

Line 
1/* $Id: logging.h 2 2009-10-12 09:51:22Z mamonski $ */
2/*
3 *  FedStage DRMAA utilities library
4 *  Copyright (C) 2006-2008  FedStage Systems
5 *
6 *  This program is free software: you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation, either version 3 of the License, or
9 *  (at your option) any later version.
10 *
11 *  This program is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __DRMAA_UTILS__LOGGING_H
21#define __DRMAA_UTILS__LOGGING_H
22
23#ifdef HAVE_CONFIG_H
24#       include <config.h>
25#endif
26
27#include <stdio.h>
28
29#include <drmaa_utils/compat.h>
30#include <drmaa_utils/util.h>
31
32#define _log_fmt(level, kind, args) \
33        do { \
34                if( (int)fsd_verbose_level <= level ) \
35                        _fsd_log( level, __FILE__, __FUNCTION__, kind, \
36                                        fsd_asprintf args ); \
37        } while(0)
38
39#define _log_empty(level, kind) \
40        do { \
41                if( (int)fsd_verbose_level <= level ) \
42                        _fsd_log( level, __FILE__, __FUNCTION__, kind, NULL ); \
43        } while(0)
44
45#define _log_nop \
46        do { /* nothing */ } while(0)
47
48#ifdef DEBUGGING
49#       define fsd_log_trace(args)   _log_fmt(FSD_LOG_TRACE, _FSD_LOG_MSG, args)
50#       define fsd_log_debug(args)   _log_fmt(FSD_LOG_DEBUG, _FSD_LOG_MSG, args)
51#       define fsd_log_enter(args)   _log_fmt(FSD_LOG_TRACE, _FSD_LOG_ENTER, args)
52# define fsd_log_return(args)  _log_fmt(FSD_LOG_TRACE, _FSD_LOG_RETURN, args)
53#else /* ! DEBUGGING */
54#       define fsd_log_trace(args)   _log_nop
55#       define fsd_log_debug(args)   _log_nop
56#       define fsd_log_enter(args)   _log_nop
57#       define fsd_log_return(args)  _log_nop
58#endif
59
60#define fsd_log_info(args)     _log_fmt(FSD_LOG_INFO, _FSD_LOG_MSG, args)
61#define fsd_log_warning(args)  _log_fmt(FSD_LOG_WARNING, _FSD_LOG_MSG, args)
62#define fsd_log_error(args)    _log_fmt(FSD_LOG_ERROR, _FSD_LOG_MSG, args)
63#define fsd_log_fatal(args)    _log_fmt(FSD_LOG_FATAL, _FSD_LOG_MSG, args)
64
65enum{ _FSD_LOG_MSG, _FSD_LOG_ENTER, _FSD_LOG_RETURN };
66void _fsd_log( int level, const char *file, const char *function,
67        int kind, char *message );
68
69void fsd_log_fmt( int level, const char *fmt, ... )
70        __attribute__(( format( printf, 2, 3 ) ));
71
72void fsd_log_fmtv( int level, const char *fmt, va_list args );
73
74void fsd_log_stacktrace( int skip, int limit );
75
76
77/**
78 * Specify place where log messages shall be written.
79 * By default they are written to standard error stream (2).
80 * @param fd   File descriptor to write to.
81 */
82void
83fsd_set_logging_fd( int fd );
84
85typedef enum {
86        FSD_LOG_ALL,
87        FSD_LOG_TRACE,
88        FSD_LOG_DEBUG,
89        FSD_LOG_INFO,
90        FSD_LOG_WARNING,
91        FSD_LOG_ERROR,
92        FSD_LOG_FATAL,
93        FSD_LOG_NONE
94} fsd_verbose_level_t;
95
96void
97fsd_set_verbosity_level( fsd_verbose_level_t level );
98
99extern fsd_verbose_level_t fsd_verbose_level;
100
101#endif /* __DRMAA_UTILS__LOGGING_H */
102
Note: See TracBrowser for help on using the repository browser.