📄 seslogerr.h
字号:
/****************************************************************************
*
* (c) Copyright 2006 by SCADA Enterprise Solutions Inc
* All rights reserved
*
* NAME:
*
* sesLogErr.H -- This is the header file for sesLogErr class.
* This object is specially designed to facilitate
* error logging.
*
* AUTHOR: Wai Tse
*
* DESCRIPTION:
*
* This class allows other objects to build error context for logging
* by a sequence of throws and catches. This way each module can add
* in appropriate details before reporting the error. The error can be
* logged to the default system log file (sysLog) or any other
* log file specified. It also contains methods to set errors,
* add error context, or to clear the error context.
*
* REVISION HISTORY:
*
* 05-Feb-2006 Wai Tse Created the initial version.
*
***************************************************************************/
#ifndef SES_LOG_ERROR_H
#define SES_LOG_ERROR_H
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "sesConst.H"
#define MAX_NUM_ERR 16
#define MAX_ERROR_LEVEL 7
#define NO_ERROR 0
#define TAB_STRING "| "
#define DEFAULT_ERR_FILE "/opt/ems/scada/env/sysLog"
class sesLogErr
{
public:
sesLogErr (const char *srcname,
const char *logFileName);
~sesLogErr ();
void logError ();
void logError (const string& errMsg,
const char *procName);
void logError (const char *errMsg,
const char *procName);
void setError (const string& errMsg,
const char *procName);
void setError (const char *errMsg,
const char *procName);
void errorContext (const string& errMsg,
const char *procName);
void errorContext (const char *errMsg,
const char *procName);
void resetError ();
private:
void stackContext(); // local static member function
typedef struct {
string srcName;
string errText;
} type_errList; // error messages table
type_errList errList_[MAX_NUM_ERR]; // error list (1st rec not used)
int _levelError; // number of error levels logged
char _srcName[TMP_STRING_SIZE]; // name of the source program
char _logFileName[TMP_STRING_SIZE]; // name of the error log file
char _tmpStr[TMP_STRING_SIZE]; // temporary string
ofstream _logFile; // pointer to the error log file
string _errBuff; // for dumping strings
string _errStr; // string for temporary usage
string _netTab; // tab spacing for nested error messages
struct stat _fstat; // file statistic for checking file existence
};
#endif // SES_LOG_ERROR_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -