EPICS Base  7.0.7.0
 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(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  const char *pformat, ...) EPICS_PRINTF_STYLE(2,3);
122 
136 LIBCOM_API int errlogSevVprintf(const errlogSevEnum severity,
137  const char *pformat, va_list pvar);
138 
144 LIBCOM_API int errlogMessage(const char *message);
145 
152 LIBCOM_API const char * errlogGetSevEnumString(errlogSevEnum severity);
153 
159 LIBCOM_API void errlogSetSevToLog(errlogSevEnum severity);
160 
166 LIBCOM_API errlogSevEnum errlogGetSevToLog(void);
167 
174 LIBCOM_API void errlogAddListener(errlogListener listener, void *pPrivate);
175 
182 LIBCOM_API int errlogRemoveListeners(errlogListener listener,
183  void *pPrivate);
184 
193 LIBCOM_API int eltc(int yesno);
194 
201 LIBCOM_API int errlogSetConsole(FILE *stream);
202 
208 LIBCOM_API int errlogInit(int bufsize);
209 
217 LIBCOM_API int errlogInit2(int bufsize, int maxMsgSize);
218 
220 LIBCOM_API void errlogFlush(void);
221 
239 LIBCOM_API void errPrintf(long status, const char *pFileName, int lineno,
240  const char *pformat, ...) EPICS_PRINTF_STYLE(4,5);
241 
242 LIBCOM_API int errlogPrintfNoConsole(const char *pformat, ...)
243  EPICS_PRINTF_STYLE(1,2);
244 LIBCOM_API int errlogVprintfNoConsole(const char *pformat,va_list pvar);
245 
253 LIBCOM_API void errSymLookup(long status, char *pBuf, size_t bufLength);
254 
274 #define ANSI_ESC_RED "\033[31;1m"
275 #define ANSI_ESC_GREEN "\033[32;1m"
276 #define ANSI_ESC_YELLOW "\033[33;1m"
277 #define ANSI_ESC_BLUE "\033[34;1m"
278 #define ANSI_ESC_MAGENTA "\033[35;1m"
279 #define ANSI_ESC_CYAN "\033[36;1m"
280 #define ANSI_ESC_BOLD "\033[1m"
281 #define ANSI_ESC_RESET "\033[0m"
282 #define ANSI_RED(STR) ANSI_ESC_RED STR ANSI_ESC_RESET
283 #define ANSI_GREEN(STR) ANSI_ESC_GREEN STR ANSI_ESC_RESET
284 #define ANSI_YELLOW(STR) ANSI_ESC_YELLOW STR ANSI_ESC_RESET
285 #define ANSI_BLUE(STR) ANSI_ESC_BLUE STR ANSI_ESC_RESET
286 #define ANSI_MAGENTA(STR) ANSI_ESC_MAGENTA STR ANSI_ESC_RESET
287 #define ANSI_CYAN(STR) ANSI_ESC_CYAN STR ANSI_ESC_RESET
288 #define ANSI_BOLD(STR) ANSI_ESC_BOLD STR ANSI_ESC_RESET
289 #define ERL_ERROR ANSI_RED("ERROR")
290 #define ERL_WARNING ANSI_MAGENTA("WARNING")
291 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif /*INC_errlog_H*/
LIBCOM_API int errlogSevPrintf(const errlogSevEnum severity, const char *pformat,...) EPICS_PRINTF_STYLE(2
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 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 void errPrintf(long status, const char *pFileName, int lineno, const char *pformat,...) EPICS_PRINTF_STYLE(4
LIBCOM_API int errlogInit2(int bufsize, int maxMsgSize)
LIBCOM_API int errlogPrintf(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 void errlogAddListener(errlogListener listener, void *pPrivate)
LIBCOM_API const char * errlogSevEnumString[]