-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXLogManagement.cpp
More file actions
66 lines (51 loc) · 1.82 KB
/
Copy pathXLogManagement.cpp
File metadata and controls
66 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "XLogManagement.h"
XLogManagement m_log;
//==============================================================================
XLogManagement::XLogManagement()
{}
//==============================================================================
XLogManagement::~XLogManagement()
{
if(my_file.isOpen())
my_file.close();
}
//==============================================================================
void XLogManagement::initializing()
{
if(m_make_file)
my_file.setFileName(m_file->app_data("Log.txt"));
LOG("initializing...");
my_file.close();
}
//==============================================================================
void XLogManagement::makeFile(bool m_status)
{
m_make_file = m_status;
}
//==============================================================================
void XLogManagement::addText(QString m_macro_file, QString m_macro_function, int m_macro_line, QString m_text)
{
if(m_make_file)
if(!my_file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qDebug() << "cant open file: " << my_file.fileName();
return;
}
//FIXME: here we should check debug mode is enable or no
//if(m_config->get("DEBUGGING/m_debugging").toBool() == false) {
// return;
//}
QDateTime m_calender = QDateTime::currentDateTime();
QString m_date = m_calender.date().toString("yyyy/MM/dd");
QString m_time = m_calender.time().toString("hh:mm:ss");
QString m_data;
if(!m_text.isEmpty())
m_data = QString("[ %1 ][ %2 ] [ %3 ][%4][%5]: %6").arg(m_date).arg(m_time).arg(m_macro_file).arg(m_macro_function).arg(m_macro_line).arg(m_text);
else
m_data = QString("[ %1 ][ %2 ] [ %3 ][%4][%5]: emited.").arg(m_date).arg(m_time).arg(m_macro_file).arg(m_macro_function).arg(m_macro_line);
qDebug() << m_data;
m_data.append("\n");
if(m_make_file) {
my_file.write(m_data.toUtf8());
my_file.close();
}
}