Skip to content

Commit 508471b

Browse files
committed
Merge pull request #1247 from Diapolo/Win_open_debug_logfile
Windows: open debug.log file via Bitcoin-Qt
2 parents b66737e + 4d3dda5 commit 508471b

File tree

5 files changed

+81
-1
lines changed

5 files changed

+81
-1
lines changed

src/qt/forms/rpcconsole.ui

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,42 @@
204204
</widget>
205205
</item>
206206
<item row="11" column="0">
207+
<spacer name="verticalSpacer_2">
208+
<property name="orientation">
209+
<enum>Qt::Vertical</enum>
210+
</property>
211+
<property name="sizeHint" stdset="0">
212+
<size>
213+
<width>20</width>
214+
<height>20</height>
215+
</size>
216+
</property>
217+
</spacer>
218+
</item>
219+
<item row="12" column="0">
220+
<widget class="QLabel" name="labelDebugLogfile">
221+
<property name="font">
222+
<font>
223+
<weight>75</weight>
224+
<bold>true</bold>
225+
</font>
226+
</property>
227+
<property name="text">
228+
<string>Debug logfile</string>
229+
</property>
230+
</widget>
231+
</item>
232+
<item row="13" column="0">
233+
<widget class="QPushButton" name="openDebugLogfileButton">
234+
<property name="toolTip">
235+
<string>Open the Bitcoin debug logfile from the current data directory. This can take a few seconds for large logfiles.</string>
236+
</property>
237+
<property name="text">
238+
<string>&amp;Open</string>
239+
</property>
240+
</widget>
241+
</item>
242+
<item row="14" column="0">
207243
<spacer name="verticalSpacer">
208244
<property name="orientation">
209245
<enum>Qt::Vertical</enum>

src/qt/guiutil.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@
1717
#include <QDesktopServices>
1818
#include <QThread>
1919

20+
#include <boost/filesystem.hpp>
21+
22+
#ifdef WIN32
23+
#ifdef _WIN32_WINNT
24+
#undef _WIN32_WINNT
25+
#endif
26+
#define _WIN32_WINNT 0x0501
27+
#ifdef _WIN32_IE
28+
#undef _WIN32_IE
29+
#endif
30+
#define _WIN32_IE 0x0501
31+
#define WIN32_LEAN_AND_MEAN 1
32+
#ifndef NOMINMAX
33+
#define NOMINMAX
34+
#endif
35+
#include "shlwapi.h"
36+
#endif
37+
2038
namespace GUIUtil {
2139

2240
QString dateTimeStr(const QDateTime &date)
@@ -214,6 +232,17 @@ bool isObscured(QWidget *w)
214232
&& checkPoint(QPoint(w->width()/2, w->height()/2), w));
215233
}
216234

235+
void openDebugLogfile()
236+
{
237+
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
238+
239+
#ifdef WIN32
240+
if (boost::filesystem::exists(pathDebug))
241+
/* Open debug.log with the associated application */
242+
ShellExecuteA((HWND)0, (LPCSTR)"open", (LPCSTR)pathDebug.string().c_str(), NULL, NULL, SW_SHOWNORMAL);
243+
#endif
244+
}
245+
217246
ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *parent):
218247
size_threshold(size_threshold), QObject(parent)
219248
{

src/qt/guiutil.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ namespace GUIUtil
7070
// Determine whether a widget is hidden behind other windows
7171
bool isObscured(QWidget *w);
7272

73+
// Open debug.log
74+
void openDebugLogfile();
75+
7376
/** Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text
7477
representation if needed. This assures that Qt can word-wrap long tooltip messages.
7578
Tooltips longer than the provided size threshold (in characters) are wrapped.

src/qt/rpcconsole.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ RPCConsole::RPCConsole(QWidget *parent) :
9090
ui->messagesWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
9191
ui->messagesWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
9292

93+
#ifndef WIN32
94+
// Show Debug logfile label and Open button only for Windows
95+
ui->labelDebugLogfile->setVisible(false);
96+
ui->openDebugLogfileButton->setVisible(false);
97+
#endif
98+
9399
// Install event filter for up and down arrow
94100
ui->lineEdit->installEventFilter(this);
95101

@@ -101,6 +107,7 @@ RPCConsole::RPCConsole(QWidget *parent) :
101107
ui->messagesWidget->addAction(copyMessageAction);
102108

103109
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
110+
connect(ui->openDebugLogfileButton, SIGNAL(clicked()), this, SLOT(on_openDebugLogfileButton_clicked()));
104111

105112
startExecutor();
106113

@@ -310,3 +317,8 @@ void RPCConsole::on_tabWidget_currentChanged(int index)
310317
ui->lineEdit->setFocus();
311318
}
312319
}
320+
321+
void RPCConsole::on_openDebugLogfileButton_clicked()
322+
{
323+
GUIUtil::openDebugLogfile();
324+
}

src/qt/rpcconsole.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class RPCConsole: public QDialog
3232

3333
private slots:
3434
void on_lineEdit_returnPressed();
35-
3635
void on_tabWidget_currentChanged(int index);
36+
void on_openDebugLogfileButton_clicked();
3737

3838
public slots:
3939
void clear();

0 commit comments

Comments
 (0)