summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-09-30 19:53:49 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-09-30 19:53:49 +0300
commit7b91248d621b561c8c38c0ca8ad69ef51107db33 (patch)
tree50212422a33fd8651c722a016b3f1ff7a2ec3724 /src
parentf6ec6ec5f60a72df8c4eda5c956de66b163052a8 (diff)
Netlib: ability to print dates in network log
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/res/resource.rc15
-rw-r--r--src/mir_app/src/netlib_log.cpp42
-rw-r--r--src/mir_app/src/resource.h1
3 files changed, 35 insertions, 23 deletions
diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc
index 95dc5df7be..84368c873e 100644
--- a/src/mir_app/res/resource.rc
+++ b/src/mir_app/res/resource.rc
@@ -229,17 +229,19 @@ BEGIN
GROUPBOX "Show",IDC_STATIC,6,2,302,118
CONTROL "Tree1",IDC_FILTER,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_NOTOOLTIPS | TVS_NONEVENHEIGHT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,14,13,160,81
CONTROL "Received bytes",IDC_DUMPRECV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,13,122,10
- CONTROL "Sent bytes",IDC_DUMPSENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,26,122,10
+ CONTROL "Sent bytes",IDC_DUMPSENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,25,122,10
CONTROL "Additional data due to proxy communication",IDC_DUMPPROXY,
- "Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,181,39,122,18
- CONTROL "SSL traffic",IDC_DUMPSSL,"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,181,56,122,10
- CONTROL "Text dumps where available",IDC_TEXTDUMPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,69,122,10
- CONTROL "Auto-detect text",IDC_AUTODETECTTEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,83,122,10
- CONTROL "Calling modules' names",IDC_SHOWNAMES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,96,122,10
+ "Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,181,37,122,18
+ CONTROL "SSL traffic",IDC_DUMPSSL,"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,181,54,122,10
+ CONTROL "Text dumps where available",IDC_TEXTDUMPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,66,122,10
+ CONTROL "Auto-detect text",IDC_AUTODETECTTEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,79,122,10
+ CONTROL "Calling modules' names",IDC_SHOWNAMES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,91,122,10
+ CONTROL "Print dates",IDC_SHOWDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,104,122,10
COMBOBOX IDC_TIMEFORMAT,14,100,160,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Log to",IDC_STATIC,6,122,302,66
CONTROL "OutputDebugString()",IDC_TOOUTPUTDEBUGSTRING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,132,122,10
CONTROL "File",IDC_TOFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,146,44,10
+ CONTROL "Rotate logs",IDC_LOGROTATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,147,146,153,10
EDITTEXT IDC_FILENAME,14,159,270,12,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_FILENAMEBROWSE,288,159,15,12
LTEXT "",IDC_PATH,14,174,294,10
@@ -251,7 +253,6 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,226,294,10
DEFPUSHBUTTON "OK",IDOK,194,241,54,14
PUSHBUTTON "Cancel",IDCANCEL,254,241,54,14
- CONTROL "Rotate logs",IDC_LOGROTATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,147,146,153,10
END
IDD_OPT_SOUND DIALOGEX 0, 0, 316, 252
diff --git a/src/mir_app/src/netlib_log.cpp b/src/mir_app/src/netlib_log.cpp
index d599851694..21a13e8769 100644
--- a/src/mir_app/src/netlib_log.cpp
+++ b/src/mir_app/src/netlib_log.cpp
@@ -36,7 +36,7 @@ extern HANDLE hConnectionHeaderMutex;
struct {
HWND hwndOpts;
bool toOutputDebugString, toFile, toLog;
- bool showUser, rotateLogs;
+ bool showUser, rotateLogs, bPrintDate;
bool dumpSent, dumpRecv, dumpProxy, dumpSsl;
bool textDumps, autoDetectText;
int timeFormat;
@@ -63,6 +63,7 @@ static void InitLog()
logOptions.dumpSsl = db_get_b(0, "Netlib", "DumpSsl", false) != 0;
logOptions.textDumps = db_get_b(0, "Netlib", "TextDumps", true) != 0;
logOptions.autoDetectText = db_get_b(0, "Netlib", "AutoDetectText", true) != 0;
+ logOptions.bPrintDate = db_get_b(0, "Netlib", "PrintDate", false) != 0;
logOptions.timeFormat = db_get_b(0, "Netlib", "TimeFormat", TIMEFORMAT_HHMMSS);
logOptions.rotateLogs = db_get_b(0, "Netlib", "RotateLogs", false);
logOptions.showUser = db_get_b(0, "Netlib", "ShowUser", true) != 0;
@@ -133,24 +134,26 @@ public:
bool OnInitDialog() override
{
logOptions.hwndOpts = m_hwnd;
+
+ CheckDlgButton(m_hwnd, IDC_TOFILE, logOptions.toFile ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_DUMPSSL, logOptions.dumpSsl ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_DUMPRECV, logOptions.dumpRecv ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_DUMPSENT, logOptions.dumpSent ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_SHOWDATE, logOptions.bPrintDate ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_SHOWNAMES, logOptions.showUser ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_DUMPPROXY, logOptions.dumpProxy ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_DUMPSSL, logOptions.dumpSsl ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_TEXTDUMPS, logOptions.textDumps ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_LOGROTATE, logOptions.rotateLogs ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_AUTODETECTTEXT, logOptions.autoDetectText ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_SHOWTHISDLGATSTART, db_get_b(0, "Netlib", "ShowLogOptsAtStart", 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_TOOUTPUTDEBUGSTRING, logOptions.toOutputDebugString ? BST_CHECKED : BST_UNCHECKED);
for (auto &it : szTimeFormats)
cmbTimeFormat.AddString(TranslateW(it));
cmbTimeFormat.SetCurSel(logOptions.timeFormat);
- CheckDlgButton(m_hwnd, IDC_SHOWNAMES, logOptions.showUser ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_TOOUTPUTDEBUGSTRING, logOptions.toOutputDebugString ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_TOFILE, logOptions.toFile ? BST_CHECKED : BST_UNCHECKED);
edtFileName.SetText(logOptions.tszUserFile);
SetDlgItemText(m_hwnd, IDC_PATH, logOptions.tszFile);
- CheckDlgButton(m_hwnd, IDC_SHOWTHISDLGATSTART, db_get_b(0, "Netlib", "ShowLogOptsAtStart", 0) ? BST_CHECKED : BST_UNCHECKED);
ptrA szRun(db_get_sa(0, "Netlib", "RunAtStart"));
if (szRun)
@@ -190,18 +193,19 @@ public:
GetDlgItemText(m_hwnd, IDC_PATH, str, _countof(str));
logOptions.tszFile = rtrimw(str);
+ db_set_b(0, "Netlib", "ToFile", IsDlgButtonChecked(m_hwnd, IDC_TOFILE));
+ db_set_b(0, "Netlib", "DumpSsl", IsDlgButtonChecked(m_hwnd, IDC_DUMPSSL));
db_set_b(0, "Netlib", "DumpRecv", IsDlgButtonChecked(m_hwnd, IDC_DUMPRECV));
db_set_b(0, "Netlib", "DumpSent", IsDlgButtonChecked(m_hwnd, IDC_DUMPSENT));
+ db_set_b(0, "Netlib", "ShowUser", IsDlgButtonChecked(m_hwnd, IDC_SHOWNAMES));
db_set_b(0, "Netlib", "DumpProxy", IsDlgButtonChecked(m_hwnd, IDC_DUMPPROXY));
- db_set_b(0, "Netlib", "DumpSsl", IsDlgButtonChecked(m_hwnd, IDC_DUMPSSL));
+ db_set_b(0, "Netlib", "PrintDate", IsDlgButtonChecked(m_hwnd, IDC_SHOWDATE));
db_set_b(0, "Netlib", "TextDumps", IsDlgButtonChecked(m_hwnd, IDC_TEXTDUMPS));
+ db_set_b(0, "Netlib", "RotateLogs", IsDlgButtonChecked(m_hwnd, IDC_LOGROTATE));
db_set_b(0, "Netlib", "AutoDetectText", IsDlgButtonChecked(m_hwnd, IDC_AUTODETECTTEXT));
- db_set_b(0, "Netlib", "ShowUser", IsDlgButtonChecked(m_hwnd, IDC_SHOWNAMES));
- db_set_b(0, "Netlib", "ToOutputDebugString", IsDlgButtonChecked(m_hwnd, IDC_TOOUTPUTDEBUGSTRING));
db_set_b(0, "Netlib", "ShowLogOptsAtStart", IsDlgButtonChecked(m_hwnd, IDC_SHOWTHISDLGATSTART));
- db_set_b(0, "Netlib", "ToFile", IsDlgButtonChecked(m_hwnd, IDC_TOFILE));
- db_set_b(0, "Netlib", "RotateLogs", IsDlgButtonChecked(m_hwnd, IDC_LOGROTATE));
-
+ db_set_b(0, "Netlib", "ToOutputDebugString", IsDlgButtonChecked(m_hwnd, IDC_TOOUTPUTDEBUGSTRING));
+
db_set_b(0, "Netlib", "TimeFormat", cmbTimeFormat.GetCurSel());
TVITEMEX tvi = {};
@@ -327,7 +331,7 @@ int NetlibLog_Worker(NetlibUser *nlu, const char *pszMsg, int flags)
return 1;
LARGE_INTEGER liTimeNow;
- char szTime[32], szHead[128];
+ char szDate[32], szTime[32], szHead[128];
switch (logOptions.timeFormat) {
case TIMEFORMAT_HHMMSS:
GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, nullptr, nullptr, szTime, _countof(szTime));
@@ -349,18 +353,24 @@ int NetlibLog_Worker(NetlibUser *nlu, const char *pszMsg, int flags)
break;
default:
- szTime[0] = '\0';
+ szTime[0] = 0;
break;
}
+ if (logOptions.bPrintDate) {
+ GetDateFormatA(LOCALE_USER_DEFAULT, 0, nullptr, "yyyy-MM-dd", szDate, _countof(szDate));
+ mir_strcat(szDate, " ");
+ }
+ else szDate[0] = 0;
+
if (flags & MSG_NOTITLE)
szHead[0] = 0;
else {
char *szUser = (logOptions.showUser) ? (nlu == nullptr ? nullptr : nlu->user.szSettingsModule) : nullptr;
if (szUser)
- mir_snprintf(szHead, "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser);
+ mir_snprintf(szHead, "[%s%s%04X] [%s] ", szDate, szTime, GetCurrentThreadId(), szUser);
else
- mir_snprintf(szHead, "[%s%04X] ", szTime, GetCurrentThreadId());
+ mir_snprintf(szHead, "[%s%s%04X] ", szDate, szTime, GetCurrentThreadId());
}
if (logOptions.toOutputDebugString) {
diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h
index f30af17e39..b104c2ef1e 100644
--- a/src/mir_app/src/resource.h
+++ b/src/mir_app/src/resource.h
@@ -215,6 +215,7 @@
#define IDC_REMOVETEMP 1030
#define IDC_SHOWNAMES 1031
#define IDC_ABOUT 1032
+#define IDC_SHOWDATE 1032
#define IDC_MYNOTES 1033
#define IDC_TRAYONLYFORINACTIVE 1034
#define IDC_POPUPONLYFORINACTIVE 1035