Home > Software engineering >  Error C2039 "ms_path" : not a member of the "Log"
Error C2039 "ms_path" : not a member of the "Log"

Time:10-01

# # ifndef __LOG_H_
# define __LOG_H_

//STD
#include
#include
#include
#include
#include

1//# define HTML_LOG output is HTML
2//# define TXT_LOG for output TXT format

A class Log
{
Private:
The static STD: : ofstream ms_file;//the log file stream
The static const char * ms_path;//the log file path
Static int ms_logLevel;//less than logLevel log will be printed
Static int ms_logFileType;//the log file type

Int m_nowLevel;
STD: : string * m_theFunctionName;//enter the function name

Public:
The static void s_init (const char * i_path, int i_logLevel, int i_fileType);
The static void s_stop ();
The static const char * endl;

The Log (const char * funcName, int logLevel);
~ the Log ();

Template
Void the debug (Type MSG);
Template
Log& Operator};
//initialize static member variables
STD: : ofstream Log: : ms_file;
Const char * Log: : ms_path=NULL;//the log file path
Int the Log: : ms_logLevel=0;//less than logLevel log will be printed
Int the Log: : ms_logFileType=0;//the log file type
Const char * Log: : endl="\ n";

The inline
Void the Log: : s_init (const char * i_path, int i_logLevel, int i_fileType)
{
Ms_path=i_path;
Ms_logLevel=i_logLevel;
Ms_logFileType=i_fileType;
Ms_file. Open (ms_path, STD: : ios: : out | STD: : ios: : trunc);

if(! Ms_file)
{
Ms_file. Close ();
STD: : cout & lt; <"ERROR. The Initializing the Log: : path. The path does not exist:"
exit(1);
}
If (ms_logFileType==HTML_LOG)
{
Const char * utf8header="& lt; The content-type HTTP - equiv=meta \ '\ "Content=" text/HTML. Charset=utf-8 \ "/& gt;";
Ms_file & lt; Const char * styleType="& lt; head> <style type=\ \ "text/CSS" & gt; R {color: red} {color: blue} b & lt;/style> ";
Ms_file & lt; <styleType;
Log: : endl="& lt; Br> ";
}
}

The inline
Void the Log: : s_stop ()
{
Ms_file. Close ();
}

//system current time
The inline
STD: : string get_cur_datetime (const char * format)
{
Time_t ttime=time (NULL);
* a datetime struct tm=localtime (& amp; Ttime);
Char datetime_str [64].
Strftime (datetime_str, sizeof (datetime_str), format, and datetime);
Return datetime_str;
}

The inline
Log: : Log (const char * funcName, int level)
: m_theFunctionName (0), m_nowLevel (level)
{
If (m_nowLevel & lt;={ms_logLevel)
If (ms_logFileType==TXT_LOG) {
Ms_file & lt; <"[" & lt; & lt; get_cur_datetime (" % d % m - % Y] [m H % : % : % S") & lt; & lt; "] "
<"[Enter the function] <" M_theFunctionName=new STD: : string (funcName);
}
Else if (ms_logFileType==HTML_LOG) {
Ms_file & lt; <" [" & lt; & lt; get_cur_datetime (" % d % m - % Y] [m H % : % : % S ") & lt; & lt; "] "
<" [Enter the function] "
";
M_theFunctionName=new STD: : string (funcName);
}
The else
{
STD: : cout & lt; <"ERROR. The File type can 't define." & lt; }
}
}

The inline
Log: : ~ the Log ()
{
If (m_nowLevel & lt;={ms_logLevel)
If (ms_logFileType==TXT_LOG) {
Ms_file & lt; <"[" & lt; & lt; get_cur_datetime (" % d % m - % Y] [m H % : % : % S") & lt; & lt; "] "
<"[the Exit function] <" <* m_theFunctionName & lt; The delete m_theFunctionName;
}
Else if (ms_logFileType==HTML_LOG) {
Ms_file & lt; <" [" & lt; & lt; get_cur_datetime (" % d % m - % Y] [m H % : % : % S ") & lt; & lt; "] "
<" [Exit function] " <* m_theFunctionName & lt; <"
";
The delete m_theFunctionName;
}
The else
{
STD: : cout & lt; <"ERROR. The File type can 't define." & lt; }
}
}

Template
The inline
Void the Log: : debug (Type MSG)
{
If (m_nowLevel & lt;=ms_logLevel)
{
If (ms_logFileType==TXT_LOG)
{
Ms_file & lt; }
Else if (ms_logFileType==HTML_LOG)
{
Ms_file & lt; <""
";
}
The else
{
STD: : cout & lt; <"ERROR. The File type can 't define." & lt; }
}
}

Template
The inline
Log& Log: : operator{
If (m_nowLevel & lt;=ms_logLevel)
{
If (ms_logFileType==TXT_LOG)
{
Ms_file & lt; }
Else if (ms_logFileType==HTML_LOG)
{
Ms_file & lt; <"" ";
}
The else
{
STD: : cout & lt; <"ERROR. The File type can 't define." & lt; }
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related