Files
interactive/application/sp-console(down)/Common/.svn/pristine/95/95b8ca6f3e782a608da645ec17123ec0f0922c23.svn-base
T
2026-08-07 17:38:18 +09:00

76 lines
1.5 KiB
Plaintext

#ifndef __DSLOG_H__
#define __DSLOG_H__
#pragma once
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
// Log Level
#define DSLL_STATE 0x0001
#define DSLL_INFO 0x0002
#define DSLL_ERROR 0x0004
#define DSLL_DEBUG 0x0008
#define LOG(s) (__FILE__ " : " s)
class CDSLog
{
// Methods
public:
CDSLog(DWORD dwMode = modeDebug, DWORD dwLevel = DSLL_STATE, LPSTR szFileName = NULL, BOOL bAppend = TRUE, BOOL bDaily = TRUE);
virtual ~CDSLog();
inline void Print(DWORD dwLevel, LPSTR pszFormat, ...) {
if (!(dwLevel & m_dwLevel))
return;
va_list val;
va_start(val, pszFormat);
_Print(pszFormat, val);
va_end(val);
}
void EventLog(WORD wType, LPSTR pszFormat, ...);
void EventLogError(LPSTR pszMsg);
void EventLogWSAError(LPSTR pszMsg);
void SetMode(DWORD dwMode);
void SetLevel(DWORD dwLevel);
void SetFile(LPSTR pszFileName, BOOL bAppend = TRUE, BOOL bDaily = TRUE);
void SetEventSource(LPSTR pszEventSource);
private:
void _Print(LPSTR pszFormat, va_list val);
void _PrintLine(LPSTR pszLine);
void OpenFile();
void CloseFile();
void MakeSurfix(LPSTR pszBuf);
// Properties
protected:
UINT64 m_nLastLogTime;
CHAR m_szLastLogDay[7];
LPSTR m_pszFileName;
HANDLE m_hFile;
LPSTR m_pszEventSource;
BOOL m_bDebugMode, m_bFileMode, m_bConsoleMode;
DWORD m_dwLevel;
BOOL m_bAppend, m_bDaily;
public:
static const DWORD modeDebug;
static const DWORD modeFile;
static const DWORD modeConsole;
static const CHAR m_szExt[];
};
#endif