Final FPC мукышщт
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -75,7 +75,9 @@ backup/
|
||||
*.ppu
|
||||
*.o
|
||||
*.or
|
||||
FPCTests/*.ico
|
||||
FPCTest/*.ico
|
||||
FPCTest/test.log
|
||||
FPCTest/test2.log
|
||||
*.ini
|
||||
|
||||
Tests/Win32
|
||||
46
AG.Logs.pas
46
AG.Logs.pas
@@ -2,6 +2,10 @@ unit AG.Logs;
|
||||
|
||||
interface
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$UNDEF MSWINDOWS}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}{$IFDEF FPC}Windows{$ELSE}Winapi.Windows{$ENDIF},{$ENDIF}
|
||||
{$IFDEF FPC}FGL{$ELSE}System.Generics.Collections{$ENDIF},
|
||||
@@ -9,9 +13,7 @@ uses
|
||||
{$IFDEF FPC}Classes{$ELSE}System.Classes{$ENDIF},
|
||||
{$IFDEF FPC}DateUtils{$ELSE}System.DateUtils{$ENDIF},
|
||||
{$IFDEF FPC}SyncObjs{$ELSE}System.SyncObjs{$ENDIF}
|
||||
{$IFNDEF MSWINDOWS},
|
||||
{$IFNDEF FPC}System.IOUtils{$ENDIF}
|
||||
{$ENDIF};
|
||||
{$IFNDEF MSWINDOWS}{$IFNDEF FPC},System.IOUtils{$ENDIF}{$ENDIF};
|
||||
|
||||
type
|
||||
TAGLog=class abstract
|
||||
@@ -40,7 +42,7 @@ type
|
||||
TAGDiskLog=class(TAGLog)
|
||||
strict protected
|
||||
{$IFNDEF MSWINDOWS}
|
||||
Stream:TStream;
|
||||
Stream:TFileStream;//TStream;
|
||||
{$ELSE}
|
||||
buf1:WideString;
|
||||
onbuf:boolean;
|
||||
@@ -106,6 +108,9 @@ type
|
||||
destructor Destroy();overload;override;
|
||||
end;
|
||||
|
||||
const
|
||||
CharSize=SizeOf(char);//{$IFDEF FPC}1{$ELSE}2{$ENDIF};
|
||||
|
||||
Implementation
|
||||
|
||||
constructor TAGLog.Create();
|
||||
@@ -191,13 +196,26 @@ ThreadHandle:=CreateThread(nil,0,{$IFDEF FPC}Self.MethodAddress('Init'){$ELSE}ad
|
||||
var
|
||||
s:TBytes;
|
||||
begin
|
||||
{$IFDEF FPC}
|
||||
Stream:=nil;
|
||||
try
|
||||
Stream:=TFileStream.Create('test2.log',fmOpenRead);
|
||||
SetLength(s,Stream.Size);
|
||||
Stream.Read(s[0],Stream.Size);
|
||||
except
|
||||
SetLength(s,0);
|
||||
end;
|
||||
FreeAndNil(Stream);
|
||||
{$ELSE}
|
||||
try
|
||||
s:=TFile.ReadAllBytes(FileName);
|
||||
except
|
||||
s:=TBytes.Create();
|
||||
end;
|
||||
{$ENDIF}
|
||||
Stream:=TFileStream.Create(FileName,fmCreate+fmOpenReadWrite+fmShareDenyWrite);
|
||||
Stream.WriteBuffer(s,length(s));
|
||||
Stream.WriteBuffer(s[0],length(s));
|
||||
SetLength(s,0);
|
||||
{$ENDIF}
|
||||
inherited Create;
|
||||
end;
|
||||
@@ -206,16 +224,16 @@ end;
|
||||
procedure TAGDiskLog.Init();stdcall;
|
||||
var
|
||||
n:cardinal;
|
||||
buf:PWideChar;
|
||||
buf:PChar;
|
||||
begin
|
||||
buf:='';
|
||||
while Lock<>nil do
|
||||
begin
|
||||
Lock.Enter;
|
||||
if buf<>'' then
|
||||
WriteFile(LogHandle,buf^,2*n,n,nil);
|
||||
WriteFile(LogHandle,buf^,CharSize*n,n,nil);
|
||||
n:=Length(buf1);
|
||||
buf:=Pwidechar(Copy(buf1,0,n));
|
||||
buf:=PChar(Copy(buf1,0,n));
|
||||
buf1:='';
|
||||
Lock.Leave;
|
||||
if WantTerminate then
|
||||
@@ -223,9 +241,9 @@ begin
|
||||
Sleep(0);
|
||||
Lock.Enter;
|
||||
if buf<>'' then
|
||||
WriteFile(LogHandle,buf^,2*n,n,nil);
|
||||
WriteFile(LogHandle,buf^,CharSize*n,n,nil);
|
||||
n:=Length(buf1);
|
||||
buf:=Pwidechar(Copy(buf1,0,n));
|
||||
buf:=PChar(Copy(buf1,0,n));
|
||||
buf1:='';
|
||||
Lock.Leave;
|
||||
WantTerminate:=False;
|
||||
@@ -247,7 +265,11 @@ var
|
||||
s:string;
|
||||
begin
|
||||
s:=GenerateLogString(tabstr+text,o);
|
||||
Stream.WriteData(PWideChar(s),Length(s)*2);
|
||||
{$IFDEF FPC}
|
||||
Stream.Write(PChar(s)^,Length(s)*CharSize);
|
||||
{$ELSE}
|
||||
Stream.WriteData(PChar(s),Length(s)*CharSize);
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
@@ -322,7 +344,7 @@ var
|
||||
s:string;
|
||||
begin
|
||||
s:=GenerateLogString(Text,o);
|
||||
stream.Write(PWideChar(s)^,2*length(s));
|
||||
stream.Write(PChar(s)^,CharSize*length(s));
|
||||
end;
|
||||
|
||||
{TAGCallBackLog}
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
@@ -22,6 +19,7 @@
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<CommandLineParams Value="-a"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
@@ -57,11 +55,18 @@
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<TargetCPU Value="jvm"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseValgrind Value="True"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Exceptions Count="4">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
@@ -71,6 +76,9 @@
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Name Value="EReadError"/>
|
||||
</Item4>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
||||
@@ -4,22 +4,21 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="6">
|
||||
<Units Count="4">
|
||||
<Unit0>
|
||||
<Filename Value="fpcunitproject1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<WindowIndex Value="-1"/>
|
||||
<TopLine Value="-1"/>
|
||||
<CursorPos X="-1" Y="-1"/>
|
||||
<UsageCount Value="20"/>
|
||||
<CursorPos X="44" Y="21"/>
|
||||
<UsageCount Value="192"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestCase1"/>
|
||||
<CursorPos X="98" Y="24"/>
|
||||
<UsageCount Value="20"/>
|
||||
<TopLine Value="21"/>
|
||||
<CursorPos Y="42"/>
|
||||
<UsageCount Value="192"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
@@ -27,64 +26,149 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<CursorPos X="89" Y="25"/>
|
||||
<UsageCount Value="20"/>
|
||||
<CursorPos X="3" Y="6"/>
|
||||
<UsageCount Value="192"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\wininc\redef.inc"/>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\sysutils\sysutilh.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="14"/>
|
||||
<CursorPos X="29" Y="30"/>
|
||||
<UsageCount Value="10"/>
|
||||
<TopLine Value="282"/>
|
||||
<CursorPos X="17" Y="320"/>
|
||||
<UsageCount Value="4"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\wininc\base.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="636"/>
|
||||
<CursorPos X="6" Y="652"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="C:\lazarus\packager\registration\fcllaz.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<CursorPos X="3" Y="11"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit5>
|
||||
</Units>
|
||||
<JumpHistory Count="8" HistoryIndex="7">
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="31" Column="6" TopLine="15"/>
|
||||
<Caret Line="41" TopLine="21"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="31" Column="6" TopLine="15"/>
|
||||
<Caret Line="42" TopLine="21"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="33" Column="20" TopLine="17"/>
|
||||
<Caret Line="43" TopLine="21"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="25" Column="89"/>
|
||||
<Caret Line="402" TopLine="381"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="31" Column="5" TopLine="15"/>
|
||||
<Caret Line="34" Column="37" TopLine="27"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="38" Column="2" TopLine="21"/>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="292" TopLine="278"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="12" Column="50"/>
|
||||
<Caret Line="39" TopLine="27"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="24" Column="98"/>
|
||||
<Caret Line="40" TopLine="27"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="41" TopLine="27"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="402" TopLine="381"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="28" Column="85" TopLine="27"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="292" TopLine="278"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="39" TopLine="27"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="40" TopLine="27"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="41" TopLine="27"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="402" TopLine="381"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="37" Column="31" TopLine="27"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="292" TopLine="278"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="39" TopLine="27"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="40" TopLine="27"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="41" TopLine="27"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="402" TopLine="381"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="212" Column="33" TopLine="196"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="216" TopLine="196"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="217" TopLine="196"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="390" Column="79" TopLine="381"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="216" TopLine="203"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="217" TopLine="203"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="390" Column="81" TopLine="381"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="217" TopLine="203"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
<Debugging>
|
||||
<BreakPoints Count="1">
|
||||
<Item1>
|
||||
<Kind Value="bpkAddress"/>
|
||||
<Address Value="168437"/>
|
||||
<WatchScope Value="wpsLocal"/>
|
||||
<WatchKind Value="wpkWrite"/>
|
||||
</Item1>
|
||||
</BreakPoints>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
||||
@@ -27,14 +27,19 @@ MultiLog:=TAGMultiLog.Create(nil);
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGDiskLog.Create('test.log'));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGRamLog.Create());
|
||||
{$IFNDEF MSWINDOWS}(MultiLog as TAGMultiLog).Logs.Add(TAGCommandLineLog.Create(GetStdHandle(STD_OUTPUT_HANDLE))){$ENDIF};
|
||||
Stream:=nil;
|
||||
try
|
||||
//s:=TFile.ReadAllBytes('test2.log');
|
||||
Stream:=TFileStream.Create('test2.log',fmOpenRead);
|
||||
SetLength(s,Stream.Size);
|
||||
Stream.Read(s[0],Stream.Size);
|
||||
except
|
||||
//s:=TBytes.Create();
|
||||
SetLength(s,0);
|
||||
end;
|
||||
FreeAndNil(Stream);
|
||||
Stream:=TFileStream.Create('test2.log',fmCreate+fmOpenReadWrite+fmShareDenyWrite);
|
||||
Stream.WriteBuffer(s,length(s));
|
||||
Stream.Write(s[0],Length(s));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGStreamLog.Create(Stream));
|
||||
SetLength(s,0);
|
||||
{(MultiLog as TAGMultiLog).Logs.Add(TAGCallBackLog.Create(procedure(s:string)
|
||||
begin
|
||||
Self.WriteLn(s);
|
||||
|
||||
Reference in New Issue
Block a user