mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Make session log directory configurable. Fixes issue #494.
This commit is contained in:
@ -68,6 +68,7 @@ const
|
||||
DEFAULT_LOGSQLNUM = 300;
|
||||
REGNAME_LOGSQLWIDTH = 'logsqlwidth';
|
||||
DEFAULT_LOGSQLWIDTH = 2000;
|
||||
REGNAME_LOGDIR = 'SessionLogsDirectory';
|
||||
REGPREFIX_SQLATTRI = 'SQL Attr ';
|
||||
REGPOSTFIX_SQL_FG = ' Foreground';
|
||||
REGPOSTFIX_SQL_BG = ' Background';
|
||||
|
@ -833,6 +833,7 @@ type
|
||||
prefRememberFilters: Boolean;
|
||||
prefLogsqlnum: Integer;
|
||||
prefLogSqlWidth: Integer;
|
||||
prefDirnameSessionLogs: String;
|
||||
prefMaxColWidth: Integer;
|
||||
prefGridRowcountStep: Integer;
|
||||
prefGridRowcountMax: Integer;
|
||||
@ -887,7 +888,6 @@ type
|
||||
DirnameCommonAppData: String;
|
||||
DirnameUserAppData: String;
|
||||
DirnameSnippets: String;
|
||||
DirnameSessionLogs: String;
|
||||
|
||||
property Delimiter: String read FDelimiter write SetDelimiter;
|
||||
procedure CallSQLHelpWithKeyword( keyword: String );
|
||||
@ -1262,9 +1262,6 @@ begin
|
||||
// Folder which contains snippet-files
|
||||
DirnameSnippets := DirnameCommonAppData + 'Snippets\';
|
||||
|
||||
// Folder for session logfiles
|
||||
DirnameSessionLogs := DirnameUserAppData + 'Sessionlogs\';
|
||||
|
||||
// SQLFiles-History
|
||||
FillPopupQueryLoad;
|
||||
|
||||
@ -1323,6 +1320,7 @@ begin
|
||||
prefMaxColWidth := DEFAULT_MAXCOLWIDTH;
|
||||
prefLogsqlnum := GetRegValue(REGNAME_LOGSQLNUM, DEFAULT_LOGSQLNUM);
|
||||
prefLogSqlWidth := GetRegValue(REGNAME_LOGSQLWIDTH, DEFAULT_LOGSQLWIDTH);
|
||||
prefDirnameSessionLogs := GetRegValue(REGNAME_LOGDIR, DirnameUserAppData + 'Sessionlogs\');
|
||||
prefCSVSeparator := GetRegValue(REGNAME_CSV_SEPARATOR, DEFAULT_CSV_SEPARATOR);
|
||||
prefCSVEncloser := GetRegValue(REGNAME_CSV_ENCLOSER, DEFAULT_CSV_ENCLOSER);
|
||||
prefCSVTerminator := GetRegValue(REGNAME_CSV_TERMINATOR, DEFAULT_CSV_TERMINATOR);
|
||||
@ -5931,16 +5929,18 @@ var
|
||||
i : Integer;
|
||||
begin
|
||||
// Ensure directory exists
|
||||
ForceDirectories( DirnameSessionLogs );
|
||||
if prefDirnameSessionLogs[Length(prefDirnameSessionLogs)] <> '\' then
|
||||
prefDirnameSessionLogs := prefDirnameSessionLogs + '\';
|
||||
ForceDirectories(prefDirnameSessionLogs);
|
||||
|
||||
// Determine free filename
|
||||
LogfilePattern := '%s %.6u.log';
|
||||
i := 1;
|
||||
FileNameSessionLog := DirnameSessionLogs + goodfilename(Format(LogfilePattern, [SessionName, i]));
|
||||
FileNameSessionLog := prefDirnameSessionLogs + goodfilename(Format(LogfilePattern, [SessionName, i]));
|
||||
while FileExists( FileNameSessionLog ) do
|
||||
begin
|
||||
inc(i);
|
||||
FileNameSessionLog := DirnameSessionLogs + goodfilename(Format(LogfilePattern, [SessionName, i]));
|
||||
FileNameSessionLog := prefDirnameSessionLogs + goodfilename(Format(LogfilePattern, [SessionName, i]));
|
||||
end;
|
||||
|
||||
// Create file handle for writing
|
||||
@ -6035,7 +6035,7 @@ end;
|
||||
}
|
||||
procedure TMainForm.menuOpenLogFolderClick(Sender: TObject);
|
||||
begin
|
||||
ShellExec( '', DirnameSessionLogs );
|
||||
ShellExec('', prefDirnameSessionLogs);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -235,16 +235,7 @@ object optionsform: Toptionsform
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Caption = 'Write SQL log to file'
|
||||
TabOrder = 4
|
||||
OnClick = Modified
|
||||
end
|
||||
object btnOpenLogFolder: TButton
|
||||
Left = 159
|
||||
Top = 68
|
||||
Width = 106
|
||||
Height = 20
|
||||
Caption = 'Open log folder ...'
|
||||
TabOrder = 5
|
||||
OnClick = btnOpenLogFolderClick
|
||||
OnClick = chkLogToFileClick
|
||||
end
|
||||
object chkLogEventErrors: TCheckBox
|
||||
Left = 159
|
||||
@ -291,6 +282,22 @@ object optionsform: Toptionsform
|
||||
TabOrder = 10
|
||||
OnClick = Modified
|
||||
end
|
||||
object editLogDir: TButtonedEdit
|
||||
Left = 159
|
||||
Top = 69
|
||||
Width = 282
|
||||
Height = 21
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Enabled = False
|
||||
Images = MainForm.ImageListMain
|
||||
RightButton.ImageIndex = 51
|
||||
RightButton.Visible = True
|
||||
TabOrder = 5
|
||||
Text = 'editLogDir'
|
||||
OnChange = Modified
|
||||
OnDblClick = editLogDirRightButtonClick
|
||||
OnRightButtonClick = editLogDirRightButtonClick
|
||||
end
|
||||
end
|
||||
object tabSQL: TTabSheet
|
||||
BorderWidth = 5
|
||||
|
@ -11,7 +11,7 @@ interface
|
||||
uses
|
||||
Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, ComCtrls, ExtCtrls, SynEditHighlighter, SynHighlighterSQL,
|
||||
SynEdit, SynMemo, VirtualTrees, SynEditKeyCmds, ActnList, SynEditMiscClasses;
|
||||
SynEdit, SynMemo, VirtualTrees, SynEditKeyCmds, ActnList, SynEditMiscClasses, StdActns;
|
||||
|
||||
type
|
||||
TShortcutItemData = record
|
||||
@ -121,7 +121,7 @@ type
|
||||
editLogSnip: TEdit;
|
||||
lblLogSnip: TLabel;
|
||||
chkLogToFile: TCheckBox;
|
||||
btnOpenLogFolder: TButton;
|
||||
editLogDir: TButtonedEdit;
|
||||
lblLogLevel: TLabel;
|
||||
chkLogEventErrors: TCheckBox;
|
||||
chkLogEventUserFiredSQL: TCheckBox;
|
||||
@ -141,7 +141,8 @@ type
|
||||
procedure DataFontsChange(Sender: TObject);
|
||||
procedure anyUpDownLimitChanging(Sender: TObject;
|
||||
var AllowChange: Boolean);
|
||||
procedure btnOpenLogFolderClick(Sender: TObject);
|
||||
procedure editLogDirRightButtonClick(Sender: TObject);
|
||||
procedure chkLogToFileClick(Sender: TObject);
|
||||
procedure chkUpdatecheckClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure chkNullBGClick(Sender: TObject);
|
||||
@ -228,6 +229,7 @@ begin
|
||||
MainReg.WriteInteger(REGNAME_TABWIDTH, updownSQLTabWidth.Position);
|
||||
MainReg.WriteInteger(REGNAME_LOGSQLNUM, updownLogLines.Position);
|
||||
MainReg.WriteInteger(REGNAME_LOGSQLWIDTH, updownLogSnip.Position);
|
||||
MainReg.WriteString(REGNAME_LOGDIR, editLogDir.Text);
|
||||
MainReg.WriteBool(REGNAME_LOG_ERRORS, chkLogEventErrors.Checked);
|
||||
MainReg.WriteBool(REGNAME_LOG_USERSQL, chkLogEventUserFiredSQL.Checked);
|
||||
MainReg.WriteBool(REGNAME_LOG_SQL, chkLogEventSQL.Checked);
|
||||
@ -321,12 +323,12 @@ begin
|
||||
Mainform.prefLogSQL := chkLogEventSQL.Checked;
|
||||
Mainform.prefLogInfos := chkLogEventInfo.Checked;
|
||||
Mainform.prefLogDebug := chkLogEventDebug.Checked;
|
||||
Mainform.prefDirnameSessionLogs := editLogDir.Text;
|
||||
Mainform.TrimSQLLog;
|
||||
if chkLogToFile.Checked then
|
||||
Mainform.ActivateFileLogging
|
||||
else if Mainform.prefLogToFile then
|
||||
Mainform.DeactivateFileLogging;
|
||||
btnOpenLogFolder.Enabled := DirectoryExists(Mainform.DirnameSessionLogs);
|
||||
Mainform.prefMaxColWidth := updownMaxColWidth.Position;
|
||||
Mainform.prefCSVSeparator := editCSVSeparator.Text;
|
||||
Mainform.prefCSVEncloser := editCSVEncloser.Text;
|
||||
@ -421,12 +423,12 @@ begin
|
||||
updownLogLines.Position := GetRegValue(REGNAME_LOGSQLNUM, DEFAULT_LOGSQLNUM);
|
||||
updownLogSnip.Position := GetRegValue(REGNAME_LOGSQLWIDTH, DEFAULT_LOGSQLWIDTH);
|
||||
chkLogToFile.Checked := GetRegValue(REGNAME_LOGTOFILE, DEFAULT_LOGTOFILE);
|
||||
editLogDir.Text := GetRegValue(REGNAME_LOGDIR, Mainform.prefDirnameSessionLogs);
|
||||
chkLogEventErrors.Checked := GetRegValue(REGNAME_LOG_ERRORS, DEFAULT_LOG_ERRORS);
|
||||
chkLogEventUserFiredSQL.Checked := GetRegValue(REGNAME_LOG_USERSQL, DEFAULT_LOG_USERSQL);
|
||||
chkLogEventSQL.Checked := GetRegValue(REGNAME_LOG_SQL, DEFAULT_LOG_SQL);
|
||||
chkLogEventInfo.Checked := GetRegValue(REGNAME_LOG_INFOS, DEFAULT_LOG_INFOS);
|
||||
chkLogEventDebug.Checked := GetRegValue(REGNAME_LOG_DEBUG, DEFAULT_LOG_DEBUG);
|
||||
btnOpenLogFolder.Enabled := DirectoryExists(Mainform.DirnameSessionLogs);
|
||||
|
||||
// Default Column-Width in DBGrids:
|
||||
updownMaxColWidth.Position := GetRegValue(REGNAME_MAXCOLWIDTH, DEFAULT_MAXCOLWIDTH);
|
||||
@ -517,12 +519,21 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{**
|
||||
Open folder with session logs
|
||||
}
|
||||
procedure Toptionsform.btnOpenLogFolderClick(Sender: TObject);
|
||||
procedure Toptionsform.editLogDirRightButtonClick(Sender: TObject);
|
||||
var
|
||||
Browse: TBrowseForFolder;
|
||||
begin
|
||||
ShellExec( '', Mainform.DirnameSessionLogs );
|
||||
// Select folder for session logs
|
||||
Browse := TBrowseForFolder.Create(Self);
|
||||
Browse.Folder := (Sender as TButtonedEdit).Text;
|
||||
Browse.DialogCaption := 'Select output directory';
|
||||
// Enable "Create new folder" button
|
||||
Browse.BrowseOptions := Browse.BrowseOptions - [bifNoNewFolderButton] + [bifNewDialogStyle];
|
||||
if Browse.Execute then begin
|
||||
(Sender as TButtonedEdit).Text := Browse.Folder;
|
||||
Modified(Sender);
|
||||
end;
|
||||
Browse.Free;
|
||||
end;
|
||||
|
||||
{**
|
||||
@ -544,6 +555,13 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.chkLogToFileClick(Sender: TObject);
|
||||
begin
|
||||
editLogDir.Enabled := TCheckBox(Sender).Checked;
|
||||
Modified(Sender);
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.chkNullBGClick(Sender: TObject);
|
||||
begin
|
||||
cboxNullBG.Enabled := (Sender as TCheckbox).Checked;
|
||||
|
Reference in New Issue
Block a user