EPICS Base  7.0.8.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
errlog.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2014 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 
11 #ifndef INC_errlog_H
12 #define INC_errlog_H
13 
28 #include <stdarg.h>
29 #include <stddef.h>
30 #include <stdio.h>
31 
32 #include "libComAPI.h"
33 #include "compilerDependencies.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
45 typedef void (*errlogListener)(void *pPrivate, const char *message);
46 
48 typedef enum {
49  errlogInfo,
50  errlogMinor,
51  errlogMajor,
52  errlogFatal
54 
56 LIBCOM_API extern int errVerbose;
57 
58 
59 #ifdef ERRLOG_INIT
60  const char *errlogSevEnumString[] = {
61  "info",
62  "minor",
63  "major",
64  "fatal"
65  };
66 #else
67 
68  LIBCOM_API extern const char * errlogSevEnumString[];
69 #endif
70 
86 #define errMessage(S, PM) \
87  errPrintf(S, __FILE__, __LINE__, " %s\n", PM)
88 
90 #define epicsPrintf errlogPrintf
91 
93 #define epicsVprintf errlogVprintf
94 
100 LIBCOM_API int errlogPrintf(EPICS_PRINTF_FMT(const char *pformat), ...)
101  EPICS_PRINTF_STYLE(1,2);
102 
108 LIBCOM_API int errlogVprintf(const char *pformat, va_list pvar);
109 
120 LIBCOM_API int errlogSevPrintf(const errlogSevEnum severity,
121  EPICS_PRINTF_FMT(const char *pformat), ...
122 ) EPICS_PRINTF_STYLE(2,3);
123 
137 LIBCOM_API int errlogSevVprintf(const errlogSevEnum severity,
138  const char *pformat, va_list pvar);
139 
145 LIBCOM_API int errlogMessage(const char *message);
146 
153 LIBCOM_API const char * errlogGetSevEnumString(errlogSevEnum severity);
154 
160 LIBCOM_API void errlogSetSevToLog(errlogSevEnum severity);
161 
167 LIBCOM_API errlogSevEnum errlogGetSevToLog(void);
168 
175 LIBCOM_API void errlogAddListener(errlogListener listener, void *pPrivate);
176 
186 LIBCOM_API int errlogRemoveListeners(errlogListener listener,
187  void *pPrivate);
188 
197 LIBCOM_API int eltc(int yesno);
198 
205 LIBCOM_API int errlogSetConsole(FILE *stream);
206 
212 LIBCOM_API int errlogInit(int bufsize);
213 
221 LIBCOM_API int errlogInit2(int bufsize, int maxMsgSize);
222 
224 LIBCOM_API void errlogFlush(void);
225 
243 LIBCOM_API void errPrintf(
244  long status, const char *pFileName, int lineno,
245  EPICS_PRINTF_FMT(const char *pformat), ...
246 ) EPICS_PRINTF_STYLE(4,5);
247 
248 LIBCOM_API int errlogPrintfNoConsole(
249  EPICS_PRINTF_FMT(const char *pformat), ...
250 ) EPICS_PRINTF_STYLE(1,2);
251 LIBCOM_API int errlogVprintfNoConsole(const char *pformat,va_list pvar);
252 
260 LIBCOM_API void errSymLookup(long status, char *pBuf, size_t bufLength);
261 
281 #define ANSI_ESC_RED "\033[31;1m"
282 #define ANSI_ESC_GREEN "\033[32;1m"
283 #define ANSI_ESC_YELLOW "\033[33;1m"
284 #define ANSI_ESC_BLUE "\033[34;1m"
285 #define ANSI_ESC_MAGENTA "\033[35;1m"
286 #define ANSI_ESC_CYAN "\033[36;1m"
287 #define ANSI_ESC_BOLD "\033[1m"
288 #define ANSI_ESC_UNDERLINE "\033[4m"
289 #define ANSI_ESC_RESET "\033[0m"
290 #define ANSI_RED(STR) ANSI_ESC_RED STR ANSI_ESC_RESET
291 #define ANSI_GREEN(STR) ANSI_ESC_GREEN STR ANSI_ESC_RESET
292 #define ANSI_YELLOW(STR) ANSI_ESC_YELLOW STR ANSI_ESC_RESET
293 #define ANSI_BLUE(STR) ANSI_ESC_BLUE STR ANSI_ESC_RESET
294 #define ANSI_MAGENTA(STR) ANSI_ESC_MAGENTA STR ANSI_ESC_RESET
295 #define ANSI_CYAN(STR) ANSI_ESC_CYAN STR ANSI_ESC_RESET
296 #define ANSI_BOLD(STR) ANSI_ESC_BOLD STR ANSI_ESC_RESET
297 #define ANSI_UNDERLINE(STR) ANSI_ESC_UNDERLINE STR ANSI_ESC_RESET
298 #define ERL_ERROR ANSI_RED("ERROR")
299 #define ERL_WARNING ANSI_MAGENTA("WARNING")
300 
302 #ifdef __cplusplus
303 }
304 #endif
305 
306 #endif /*INC_errlog_H*/
LIBCOM_API int errlogRemoveListeners(errlogListener listener, void *pPrivate)
void(* errlogListener)(void *pPrivate, const char *message)
Definition: errlog.h:45
errlogSevEnum
Definition: errlog.h:48
LIBCOM_API int errlogMessage(const char *message)
LIBCOM_API errlogSevEnum errlogGetSevToLog(void)
LIBCOM_API int errlogSetConsole(FILE *stream)
LIBCOM_API void errPrintf(long status, const char *pFileName, int lineno, EPICS_PRINTF_FMT(const char *pformat),...) EPICS_PRINTF_STYLE(4
LIBCOM_API const char * errlogGetSevEnumString(errlogSevEnum severity)
LIBCOM_API int errlogInit(int bufsize)
Compiler specific declarations.
LIBCOM_API int LIBCOM_API int errlogVprintf(const char *pformat, va_list pvar)
LIBCOM_API void errSymLookup(long status, char *pBuf, size_t bufLength)
LIBCOM_API int eltc(int yesno)
LIBCOM_API int errlogInit2(int bufsize, int maxMsgSize)
LIBCOM_API int errlogPrintf(EPICS_PRINTF_FMT(const char *pformat),...) EPICS_PRINTF_STYLE(1
LIBCOM_API int errVerbose
LIBCOM_API void errlogFlush(void)
LIBCOM_API void errlogSetSevToLog(errlogSevEnum severity)
LIBCOM_API int LIBCOM_API int errlogSevVprintf(const errlogSevEnum severity, const char *pformat, va_list pvar)
LIBCOM_API int errlogSevPrintf(const errlogSevEnum severity, EPICS_PRINTF_FMT(const char *pformat),...) EPICS_PRINTF_STYLE(2
LIBCOM_API void errlogAddListener(errlogListener listener, void *pPrivate)
LIBCOM_API const char * errlogSevEnumString[]