ADD: Force write to log window

This commit is contained in:
Alexander Koblov 2009-07-05 14:57:20 +00:00
commit cbcf8d0ac0
3 changed files with 41 additions and 21 deletions

View file

@ -3246,8 +3246,8 @@ begin
pnlCommand.Visible := gCmdLine;
edtCommand.Tag := 0;
pnlKeys.Visible := gKeyButtons;
LogSplitter.Visible := gLogWindow;
seLogWindow.Visible := gLogWindow;
LogSplitter.Visible := gLogWindow or (not miLogHide.Enabled);
seLogWindow.Visible := gLogWindow or (not miLogHide.Enabled);
seLogWindow.Font.Name := gEditorFontName;
ToggleConsole;
ToggleFileSystemWatcher;

View file

@ -55,21 +55,24 @@ type
procedure WriteLog(const sText: String; LogMsgType: TLogMsgType; bForce, bLogFile: Boolean);
end;
procedure ShowLogWindow(bShow: Boolean);
procedure ShowLogWindow(bShow: Boolean; bLock: PBoolean = nil);
procedure logWrite(const sText: String; LogMsgType: TLogMsgType = lmtInfo; bForce: Boolean = False; bLogFile: Boolean = True);
procedure logWrite(Thread: TThread; const sText: String; LogMsgType: TLogMsgType = lmtInfo; bForce: Boolean = False; bLogFile: Boolean = True);
implementation
uses
SysUtils, LCLProc, fMain, uGlobs, uFileProcs, uOSUtils;
SysUtils, LCLProc, Forms, fMain, uGlobs, uFileProcs, uOSUtils;
procedure ShowLogWindow(bShow: Boolean);
procedure ShowLogWindow(bShow: Boolean; bLock: PBoolean);
begin
if Assigned(fMain.frmMain) then
with fMain.frmMain do
begin
LogSplitter.Visible:= bShow;
seLogWindow.Visible:= bShow;
if Assigned(bLock) then
miLogHide.Enabled:= not bLock^;
Application.ProcessMessages;
end;
end;
@ -77,14 +80,18 @@ procedure logWrite(const sText: String; LogMsgType: TLogMsgType; bForce, bLogFil
var
hLogFile: Integer;
LogMsgTypeObject: TObject absolute LogMsgType;
bLock: Boolean;
begin
if (not gLogWindow) and bForce then
ShowLogWindow(True);
if Assigned(fMain.frmMain) and (gLogWindow or bForce) then // if write log to window
with fMain.frmMain.seLogWindow do
begin
CaretY:= Lines.AddObject(sText, LogMsgTypeObject) + 1;
end;
if Assigned(fMain.frmMain) then
with fMain.frmMain do
begin
if (not gLogWindow and seLogWindow.Visible) and bForce then
ShowLogWindow(True);
bLock:= not miLogHide.Enabled;
if (gLogWindow or bForce or bLock) then // if write log to window
seLogWindow.CaretY:= seLogWindow.Lines.AddObject(sText, LogMsgTypeObject) + 1;
end;
if gLogFile and bLogFile then // if write log to file
try

View file

@ -389,19 +389,32 @@ end;
procedure MainLogProc(PluginNr, MsgType: Integer; LogString: PChar); stdcall;
var
sMsg: String;
LogMsgType: TLogMsgType = lmtInfo;
bLogFile: Boolean;
bLock: Boolean = True;
Begin
sMsg:= rsMsgLogInfo;
bLogFile:= ((log_vfs_op in gLogOptions) and (log_info in gLogOptions));
case MsgType of
msgtype_connect: sMsg:= 'msgtype_connect';
msgtype_disconnect: sMsg:= 'msgtype_disconnect';
msgtype_details: sMsg:= 'msgtype_details';
msgtype_transfercomplete: sMsg:= 'msgtype_transfercomplete';
msgtype_connectcomplete: sMsg:= 'msgtype_connectcomplete';
msgtype_importanterror: sMsg:= 'msgtype_importanterror';
msgtype_operationcomplete: sMsg:= 'msgtype_operationcomplete';
msgtype_connect:
begin
sMsg:= sMsg + 'msgtype_connect';
ShowLogWindow(True, @bLock);
end;
msgtype_disconnect: sMsg:= sMsg + 'msgtype_disconnect';
msgtype_details: sMsg:= sMsg + 'msgtype_details';
msgtype_transfercomplete: sMsg:= sMsg + 'msgtype_transfercomplete';
msgtype_connectcomplete: sMsg:= sMsg + 'msgtype_connectcomplete';
msgtype_importanterror:
begin
sMsg:= rsMsgLogError + 'msgtype_importanterror';
LogMsgType:= lmtError;
bLogFile:= (log_vfs_op in gLogOptions) and (log_errors in gLogOptions);
end;
msgtype_operationcomplete: sMsg:= sMsg + 'msgtype_operationcomplete';
end;
// write log info
if (log_vfs_op in gLogOptions) and (log_info in gLogOptions) then
logWrite(rsMsgLogInfo + sMsg + ', ' + logString);
logWrite(sMsg + ', ' + logString, LogMsgType, False, bLogFile);
//DebugLN('MainLogProc ('+ sMsg + ',' + logString + ')');
End;