Development languages: C/C + +
Development tools: VS2010
Industrial PC platform: Windows 7 embedded version
Below is log screenshots, each file is a thread of print, the upper part is normal, to the lower part is wrong
2020-03-09 03:58:00. 612 & lt; GetAllParamVersion> Type '9210', the current '1900010101', the future of '9999123199', update the date '19000101023000'
The 2020-03-09 03:58:00. 612 & lt; GetAllParamVersion> Type '9220', the current '1900010101', the future of '9999123199', update the date '19000101023000'
The 2020-03-09 03:58:00. 612 & lt; GetAllParamVersion> Type '9230', the current '1900010101', the future of '9999123199', update the date '19000101023000'
The 2020-03-09 03:58:00. 614 & lt; GetAllParamVersion> Type '9240', the current '1900010101', the future of '9999123199', update the date '19000101023000'
The 2020-03-09 03:58:00. 614 & lt; GetAllParamVersion> Type '9290', the current '2019100801', the future of '9999123199', update the date '20191126145903'
327-27 06:58:35. & lt; TCP> The Send x40100c0c [0] to SC: EB3500000003
The 2019-11-27 06:58:39. 960 & lt; SendToSC> The message (0 x00100c0c), m_waitAckFlag: 0
The 2019-11-27 06:58:39. 960 & lt; TCP> The Send x00100c0c [0] to SC: EB3400000003
The 2019-11-27 06:58:39. 981 & lt; TCP> Recv the from SC: EB3500000003
The 2019-11-27 06:58:39. 981 & lt; TCP> SLE client: 6 byte (s) converted, serial id is 00.
The 2019-11-27 06:58:39. 981 & lt; SC> Receive the link test the response from the client [0]
The 2019-11-27 06:58:44. 754 & lt; TCP> Recv the from SC: EB3400000003
The 2019-11-27 06:58:44. 754 & lt; TCP> SLE client: 6 byte (s) converted, serial id is 00.
2020-03-09 07:35:09. 394 Get clock offset=0.811569, abs=0.811569
The 2020-03-09 07:35:09. 394 Did not need time sync
The 2020-03-09 07:35:39. 313 Get clock offset=0.812896, abs=0.812896
The 2020-03-09 07:35:39. 313 Did not need time sync
R1LAST HOPPER2LAST) values (' 2019-12-26 23:39:34 '0, 34);
The 2019-12-26 23:39:34. 681 insert into SETTLE_SJTSTAT (STARTSETTLETIME, SEQNO HOPPER1LAST, HOPPER2LAST) values (' 2019-12-26 23:39:34 '0, 34);
The 2019-12-26 23:39:34. 702 insert into SETTLE_SJTSTAT (STARTSETTLETIME, SEQNO HOPPER1LAST, HOPPER2LAST) values (' 2019-12-26 23:39:34 '0, 34);
The 2019-12-26 23:39:34. 732 insert into SETTLE_CASHSTAT (STARTSETTLETIME, SEQNO HOPPER1LAST, HOPPER2LAST, NOTE1LAST, NOTE2LAST, NOTERECYCLE, NOTEBOXREMAIN, COINBOXREMAIN) values (' 2019-12-26 23:39:34, 34,0,0,0,0,0,0,0);
The following is a log print code
bool CSleLog: : openLogFile ()
{
If (NULL!=m_logFile)
The fclose (m_logFile);
String logDate=TimeUtil: : getCurrentDate ();
M_logDate=logDate;
String log_base_path=m_path;
if (! File: : the exists (log_base_path))
{
File: : makePath (log_base_path);
}
Log_base_path +=logDate;
if (! File: : the exists (log_base_path))
{
File: : makePath (log_base_path);
}
The string filename=m_logModule log_base_path + "\ " + + ". The log ";
M_logFile=fopen (filename. C_str (), "at +");
If (NULL!=m_logFile)
{
String headStr=m_logModule + "" + m_version +" \ n ";
Fprintf (m_logFile, headStr c_str ());
The fflush (m_logFile);
}
Return (NULL!=m_logFile);
}
void CSleLog: : info (const char * format,... )
{
The lock (lock_type log_mutex);
Enum {
Max_buf_length=8192,
};
//if (NULL==m_logFile)
//return;
//m_currLogCount + +;
//if (m_currLogCount & gt; Max_Log_Line_Count)
//{
//openLogFile ();
//m_currLogCount=1;
//}
Try
{
String logDate=TimeUtil: : getCurrentDate ();
If (m_logDate.com pare said (logDate)!=0)
{
OpenLogFile ();
//m_currLogCount=1;
}
If (NULL==m_logFile)
return;
Char buffer [max_buf_length + 1)={0};
Va_list ap;
Va_start (ap, format);
_vsnprintf (buffer, max_buf_length, format, ap);
Va_end (ap);
The string content (buffer);
Fprintf (m_logFile, "% s % s", TimeUtil: : getCurrentTimeStamp (). The c_str (), content. c_str ());
The fflush (m_logFile);
}
The catch (... ) {}
}
CodePudding user response:
The log push asynchronous message queue lock, working inside the canCodePudding user response:
I want to understand, why will appear this problem, the file will only be occupied by a single thread, and other content is where come of, can you explain in detail