X-shooter Pipeline Reference Manual 3.8.15
xsh_msg.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2011-12-02 14:15:28 $
23 * $Revision: 1.8 $
24 * $Name: not supported by cvs2svn $
25 */
26
27#ifdef HAVE_CONFIG_H
28# include <config.h>
29#endif
30
31/*----------------------------------------------------------------------------*/
45/*----------------------------------------------------------------------------*/
48/*-----------------------------------------------------------------------------
49 Includes
50 -----------------------------------------------------------------------------*/
51
52#include "xsh_msg.h"
53
54#include <cpl.h>
55#include <stdarg.h>
56
57/*-----------------------------------------------------------------------------
58 Defines
59 -----------------------------------------------------------------------------*/
60
61#define MAXSTRINGLENGTH 1024 /* Used to pass a va_list to cpl_msg_warning */
62
63/*-----------------------------------------------------------------------------
64 Variables
65 -----------------------------------------------------------------------------*/
66static int number_of_warnings = 0;
67/* Coun't the number of warnings since initialization */
68
69/*----------------------------------------------------------------------------*/
78/*----------------------------------------------------------------------------*/
79void
81{
82 /* Initialize per recipe: */
84
85 cpl_msg_set_indentation (2);
86
87 /* CPL message format is
88 * [Time][Verbosity][domain][component] message
89 *
90 * Don't show the (variable length and wildly
91 * fluctuating) component. It interferes with
92 * indentation. The component is available anyway
93 * on CPL_MSG_DEBUG level.
94 *
95 * Don't show the time. This is available on
96 * the DEBUG level. Use esorex --time to time
97 * a recipe.
98 */
99
100 cpl_msg_set_time_off ();
101 /* Leave it to the recipe caller
102 * application to define the verbosity
103 * level cpl_msg_set_level(...);
104 */
105 cpl_msg_set_domain_on ();
106 cpl_msg_set_component_off ();
107}
108
109/*----------------------------------------------------------------------------*/
114/*----------------------------------------------------------------------------*/
115int
117{
118 return number_of_warnings;
119}
120
121/*----------------------------------------------------------------------------*/
135/*----------------------------------------------------------------------------*/
136void
137xsh_msg_warning_macro (const char *fct, const char *format, ...)
138{
139 char printbuffer[MAXSTRINGLENGTH];
140 /* Message functions should never fail, so don't rely on
141 dynamic memory allocation */
142
143 va_list al;
144
145 va_start (al, format);
146 vsnprintf (printbuffer, MAXSTRINGLENGTH - 1, format, al);
147 va_end (al);
148
149 printbuffer[MAXSTRINGLENGTH - 1] = '\0';
150
151 cpl_msg_warning (fct, "%s", printbuffer);
152
154}
155
void xsh_msg_init(void)
Initialize messaging.
Definition: xsh_msg.c:80
void xsh_msg_warning_macro(const char *fct, const char *format,...)
Print a warning message.
Definition: xsh_msg.c:137
#define MAXSTRINGLENGTH
Definition: xsh_msg.c:61
static int number_of_warnings
Definition: xsh_msg.c:66
int xsh_msg_get_warnings(void)
Get number of warnings printed so far.
Definition: xsh_msg.c:116