123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- /**************************************************************************
- *
- * Licensed Materials - Property of IBM and/or HCL
- *
- * IBM Informix Dynamic Server
- * Copyright IBM Corporation 1996, 2016
- * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
- *
- ******************************************************************************
- */
- #include <stdarg.h>
- /*
- * TRACING MODES OR FLAGS:
- * With heavy tracing there are 3 functions that the programmer uses:
- * log entries tat go to the log and trace file
- * error entries that go to the log and trace files
- * trace entries that go to the trace file only
- * trace entries can have a priority that allows us to filter lower priorities
- * trace entries also can be filtered by component if components are set
- */
- typedef enum
- {
- HT_MODE_TIME = 0x00000001, /* Add timestamp at beggining of line */
- HT_MODE_MTIME = 0x00000002, /* Use microseonds for tracing */
- HT_MODE_HEADER = 0x00000004, /* Add header to the begginign of line */
- HT_MODE_INDENT = 0x00000008, /* Indent on Function Enter */
- HT_MODE_MICRO = 0x00000010, /* Typical install */
- HT_MODE_COMPONENT = 0x00000020, /* Use components to trace */
- HT_MODE_TRACEPID = 0x00000040,
- HT_MODE_STDOUT_DUP = 0x00000080, /* Writes the log file to STDOUT */
- HT_MODE_ALL_VALID = 0x000000FF
- } HT_MODE;
- typedef enum
- {
- HT_DEBUG0 = 0x00,
- HT_DEBUG1 = 0x01,
- HT_DEBUG2 = 0x02,
- HT_DEBUG3 = 0x03,
- HT_DEBUG4 = 0x04,
- HT_DEBUG5 = 0x05,
- HT_DEBUG6 = 0x06,
- HT_DEBUG7 = 0x07,
- HT_DEBUG8 = 0x08,
- HT_DEBUG9 = 0x09
- } HT_DLEVEL;
- typedef enum
- {
- HT_E_NOERROR = 0,
- HT_E_BAD_MAGIC = 10000,
- HT_E_CANT_OPEN,
- HT_E_NOMEM,
- HT_E_BAD_PARAMS,
- HT_E_BAD_FLAGS,
- HT_E_ALREADY_INIT,
- HT_E_NOT_INIT
- } HT_E_CODE;
- typedef enum
- {
- HT_FD_LOG = 1,
- HT_FD_DBG = 2
- } HT_LOG_TYPE;
- /* To avoid write __LINE__, __FILE__ all the time, then define the following */
- #define HT_SEV_01 HT_DEBUG1,__FILE__,__LINE__
- #define HT_SEV_02 HT_DEBUG2,__FILE__,__LINE__
- #define HT_SEV_03 HT_DEBUG3,__FILE__,__LINE__
- #define HT_SEV_04 HT_DEBUG4,__FILE__,__LINE__
- #define HT_SEV_05 HT_DEBUG5,__FILE__,__LINE__
- #define HT_SEV_06 HT_DEBUG6,__FILE__,__LINE__
- #define HT_SEV_07 HT_DEBUG7,__FILE__,__LINE__
- #define HT_SEV_08 HT_DEBUG8,__FILE__,__LINE__
- #define HT_SEV_09 HT_DEBUG9,__FILE__,__LINE__
- #define TRACE_PATHSIZE 256
- #define TRACE_MAX_DATE_LEN 27 /* maximum lengths */
- #define TRACE_NOMS_DATE 20 /* date without microseconds */
- #define TRACE_MAX_MSG_LEN 10240
- #define TRACE_MAX_MSG_NUMBER 9 /* max number of formats in
- * message */
- #define TRACE_BAD_FD -1 /* opening trace file failed */
- #ifdef NT
- typedef mlong fhandle;
- #else
- typedef mint fhandle;
- #endif /* NT */
- typedef int4 severity;
- typedef struct
- {
- uint4 ht_flags; /* tracing flags */
- char ht_lfn[TRACE_PATHSIZE + 1]; /* log file name */
- fhandle ht_lfd; /* log file descriptor */
- char ht_dfn[TRACE_PATHSIZE + 1]; /* debug file name */
- fhandle ht_dfd; /* debug file descriptor */
- HT_DLEVEL ht_sev; /* debug trace level */
- char ht_header[256]; /* header for each line */
- char is_locked; /* is file locked? */
- } trace_file;
- #if defined(NT)
- #if !defined(EXPORT)
- #ifdef DLL
- #define EXPORT __declspec(dllexport)
- #else /* DLL */
- #define EXPORT __declspec(dllimport)
- #endif /* DLL */
- #endif /* EXPORT */
- #if !defined(STDCALL)
- #define STDCALL __stdcall
- #endif
- #else /* NT */
- #if !defined(EXPORT)
- #define EXPORT extern
- #endif
- #if !defined(STDCALL)
- #define STDCALL
- #endif
- #endif /* NT */
- EXPORT void STDCALL
- htenter (int severity,
- char *file_name,
- int line_number,
- char *funcname
- );
- EXPORT int STDCALL
- htexit (int severity,
- char *file_name,
- int line_number,
- int rc
- );
- void
- htrace(
- int severity,
- char *file_name,
- int line_number,
- char *format,
- ...
- );
- void
- writelog(
- char *format,
- ...
- );
- EXPORT void STDCALL
- heavytrace (HT_LOG_TYPE dest,
- char *fname,
- int lnum,
- int is_variable,
- char *format,
- va_list var_args
- );
- HT_E_CODE
- ht_trace_start(
- char *log_fn, /* IN: log file name */
- char *dbg_fn, /* IN: debug file name */
- HT_DLEVEL severity, /* IN: severity threshold for debug */
- int flags, /* IN: Flags for tracing */
- char *header_str /* IN: string to add to all messages */
- );
|