logfile.hpp
来自「ABis无线接口全套资料」· HPP 代码 · 共 111 行
HPP
111 行
/* ======================================================================== *\ | | | JOYIT Communication Technology | Copyright (C) 2003-2006, All Right Reserved. | | System: Programmable Signaling Gateway | Sub-system: MTP3 | Filename: logfile.hpp | Environment: LINUX -- Red Hat 7.2 & GNU C/C++ Compiler 2.96 | vxWorks -- Tornado 2.0 & vxWorks 5.4 | Function description: Declare the general log file management class | for my system. |\* ======================================================================== */#ifndef _LOGFILE_HPP#define _LOGFILE_HPP#ifndef _DATATYPE_HPP#include "datatype.hpp"#endifextern "C"{#ifndef _STDIO_H#include <stdio.h> // or #include <iostream.h>#endif};const ushort MAX_PREFIX = 128;const ushort MAX_SUFFIX = 128;const ushort MAX_FILENAME = 512;const ushort MAX_STRLEN = 1024;//512const ushort BUF_LEN = 64;const ushort MAX_BUF_LEN = 128;const UINT32 MAX_FILE_SIZE = 1048576L; // 1073741824; //Modify 20K->1G,2005-12-22,WJQ.const INT8 YMD_SUF = 0, // Year+Month+Day+Suffix PRE_YMD = 1, // Prefix+Year+Month+Day PRE_YMD_SUF= 2, // Prefix+Year+Month+Day+Suffix PRE_SUF = 3, // Prefix+Suffix PRE_SEQ = 4, // Prefix+Sequence number. seq act as the suffix, four byte. PRE_SEQ_SUF= 5, // Prefix+Seq+Suffix. seq occurpy four byte. SEQ_SUF = 6, // Seq+Suffix PRE_YMD_SEQ = 7, //Add 2005-12-22 , WJQ. PRE_YMDHM = 8, //Add 2005-12-25 , WJQ. FILENAME = 127;// File name already in filename[]class LogFile{public: LogFile( ); ~LogFile( );public: void Init(const char * const pre, const char * const suf, INT8 fm); void SetFileName(const char * const fn); void SetBufLength(int bl); void SetLengthLimit(UINT32 ll);public: ERRCOD_T OpenFile( ); ERRCOD_T ReOpenFile( ); ERRCOD_T CloseFile( ); void Flush( ); // Save the contents of buffer to disk file.public: void Log(const char * const msg);private: void CreateFileName( );private: char fnPrefix[MAX_PREFIX]; char fnSuffix[MAX_SUFFIX]; char filename[MAX_FILENAME]; // Max file name is not longer than 511 char; FILE * fp; char ** iBuffer; // Store the information which will be saved to disk file. int bufLength; // The length of the buffer. UINT32 lenLimit; // To limit the length of the file. k byte // Modify by Wu jianjin, 2006-06-05. INT8 fnMode; // Use which rule to create the file name. INT16 seqNo; // The sequence is three number. short lineCount;public: // Add 2006-06-02, by Wu jianjin void MovingOldLogFile( ); // Only for fnMode = FILENAME void Write2File( ); void ClearBuffer( );private: // Add 2006-06-05, by Wu jianjin. UINT32 totalFileLength;};#endif// ------------------------------------------------------------------------//// Revision list.// ==============//// 1.0, 2003-04-18, Wu jianjin// Initial version.// 1.1, 2003-05-19, Wu jianjin// Ported to vxWorks.// 2.0, 2006-06-02, Wu jianjin//// ------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?