Add documentation
This commit is contained in:
24
AG.Logs.pas
24
AG.Logs.pas
@@ -1,7 +1,7 @@
|
|||||||
//****************************************************
|
//****************************************************
|
||||||
//*Copyright (c) 2018 Artem Gavrilov *
|
//*Copyright (c) 2018 Artem Gavrilov *
|
||||||
//*Website: https://teamfnd.ru *
|
//*Website: https://teamfnd.ru *
|
||||||
//*License: MIT *
|
//*License: MIT *
|
||||||
//*Donate: https://money.yandex.ru/to/410014959153552*
|
//*Donate: https://money.yandex.ru/to/410014959153552*
|
||||||
//****************************************************
|
//****************************************************
|
||||||
unit AG.Logs;
|
unit AG.Logs;
|
||||||
@@ -58,14 +58,14 @@ type
|
|||||||
ThreadID:cardinal;
|
ThreadID:cardinal;
|
||||||
Lock:TCriticalSection;
|
Lock:TCriticalSection;
|
||||||
WantTerminate:Boolean;
|
WantTerminate:Boolean;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Stream:TStream;
|
Stream:TStream;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
public
|
|
||||||
constructor Create(const FileName:String);overload;
|
|
||||||
{$IF defined(MSWINDOWS) and not defined(FPC)}
|
{$IF defined(MSWINDOWS) and not defined(FPC)}
|
||||||
procedure Init();stdcall;
|
procedure Init();stdcall;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
public
|
||||||
|
constructor Create(const FileName:String);overload;
|
||||||
procedure Write(const Text:string;o:TObject=nil);overload;override;
|
procedure Write(const Text:string;o:TObject=nil);overload;override;
|
||||||
destructor Destroy();overload;override;
|
destructor Destroy();overload;override;
|
||||||
end;
|
end;
|
||||||
@@ -99,7 +99,7 @@ type
|
|||||||
strict protected type
|
strict protected type
|
||||||
TCallBack={$IFNDEF FPC}reference to{$ENDIF}procedure(s:string);
|
TCallBack={$IFNDEF FPC}reference to{$ENDIF}procedure(s:string);
|
||||||
var
|
var
|
||||||
CallBack:TCallBack;
|
CallBack:TCallBack;
|
||||||
public
|
public
|
||||||
constructor Create(ACallBack:TCallBack);overload;
|
constructor Create(ACallBack:TCallBack);overload;
|
||||||
procedure Write(const Text:string;o:TObject=nil);overload;override;
|
procedure Write(const Text:string;o:TObject=nil);overload;override;
|
||||||
@@ -110,10 +110,10 @@ type
|
|||||||
procedure SetIndentText(const s:string);override;
|
procedure SetIndentText(const s:string);override;
|
||||||
public
|
public
|
||||||
type
|
type
|
||||||
TLogsList={$IFDEF FPC}specialize TFPGList<TAGLog>{$ELSE}TList<TAGLog>{$ENDIF};
|
TLogsList={$IFDEF FPC}specialize TFPGList<TAGLog>{$ELSE}TList<TAGLog>{$ENDIF};
|
||||||
var
|
var
|
||||||
Logs:TLogsList;
|
Logs:TLogsList;
|
||||||
constructor Create(Default:TLogsList);overload;
|
constructor Create(ALogs:TLogsList=nil);overload;
|
||||||
procedure Write(const Text:string;o:TObject=nil);overload;override;
|
procedure Write(const Text:string;o:TObject=nil);overload;override;
|
||||||
procedure Indent();override;
|
procedure Indent();override;
|
||||||
procedure UnIndent();override;
|
procedure UnIndent();override;
|
||||||
@@ -406,11 +406,11 @@ for i in Logs do
|
|||||||
i.IndentText:=s;
|
i.IndentText:=s;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TAGMultiLog.Create(Default:TLogsList);
|
constructor TAGMultiLog.Create(ALogs:TLogsList=nil);
|
||||||
begin
|
begin
|
||||||
//inherited Create;
|
//inherited Create;
|
||||||
if Default<>nil then
|
if Default<>nil then
|
||||||
Logs:=Default
|
Logs:=ALogs
|
||||||
else
|
else
|
||||||
Logs:=TLogsList.Create;
|
Logs:=TLogsList.Create;
|
||||||
end;
|
end;
|
||||||
|
|||||||
117
DOC_EN.MD
Normal file
117
DOC_EN.MD
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
|
||||||
|
# Description of AG.Logs library
|
||||||
|
|
||||||
|
## TAGLog
|
||||||
|
|
||||||
|
It is abstract class for using in any parts of code.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### class function GenerateLogString(const s:string;o:TObject=nil):string;static;
|
||||||
|
|
||||||
|
Function for add time and object information (if o is not nil) to string
|
||||||
|
|
||||||
|
+ #### procedure Indent();
|
||||||
|
|
||||||
|
Procedure for add ident to all next strings.
|
||||||
|
|
||||||
|
+ #### procedure UnIndent();
|
||||||
|
|
||||||
|
Procedure for remove ident from all next strings.
|
||||||
|
|
||||||
|
+ #### procedure Write(const Text:string;o:TObject=nil);
|
||||||
|
|
||||||
|
Write string in log.
|
||||||
|
|
||||||
|
+ #### property IndentText:string;
|
||||||
|
|
||||||
|
String what using as indent symbol in log string. Default is DefOneTabStr const(two spaces).
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGRamLog
|
||||||
|
|
||||||
|
Write log in RAM buffer.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### buf:String;
|
||||||
|
|
||||||
|
Buffer when you can find log.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGDiskLog
|
||||||
|
|
||||||
|
File log.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### constructor Create(const FileName:String);
|
||||||
|
|
||||||
|
Use to create log from file name. If file not exist if will created.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGNullLog
|
||||||
|
|
||||||
|
Use if you don't need log, but don't want del logging from code.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGCommandLineLog
|
||||||
|
|
||||||
|
Write log to command line.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### constructor Create(Handele:THandle);
|
||||||
|
|
||||||
|
Use to create log from winapi handle. Use as:
|
||||||
|
|
||||||
|
`Log:=TAGCommandLineLog.Create(GetStdHandle(STD_OUTPUT_HANDLE));`
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGStreamLog
|
||||||
|
|
||||||
|
Write log to pascal stream.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### constructor Create(Astream:TStream);
|
||||||
|
|
||||||
|
Use to create log from pascal stream.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGCallBackLog
|
||||||
|
|
||||||
|
Write log to callback.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### TCallBack
|
||||||
|
|
||||||
|
Type. In delphi it is anonimus procedure, in free pascal - standart procedure. Declaration:
|
||||||
|
|
||||||
|
`TCallBack={$IFNDEF FPC}reference to{$ENDIF}procedure(s:string);`
|
||||||
|
|
||||||
|
+ #### constructor Create(ACallBack:TCallBack);
|
||||||
|
|
||||||
|
Use to create log from callback.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGMultiLog
|
||||||
|
|
||||||
|
Write all to other logs.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### TLogsList
|
||||||
|
|
||||||
|
Type for list of logs. In delphi it is `System.Generics.Collections.TList`, in free pascal - `FGL.TFPGList`. Declaration:
|
||||||
|
|
||||||
|
`TLogsList={$IFDEF FPC}specialize TFPGList<TAGLog>{$ELSE}TList<TAGLog>{$ENDIF}`
|
||||||
|
|
||||||
|
+ #### constructor Create(ALogs:TLogsList);
|
||||||
|
|
||||||
|
Use to create log from TLogsList. If ALogs is nil.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
117
DOC_RU.MD
Normal file
117
DOC_RU.MD
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
|
||||||
|
# Description of AG.Logs library
|
||||||
|
|
||||||
|
## TAGLog
|
||||||
|
|
||||||
|
It is abstract class for using in any parts of code.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### class function GenerateLogString(const s:string;o:TObject=nil):string;static;
|
||||||
|
|
||||||
|
Function for add time and object information (if o is not nil) to string
|
||||||
|
|
||||||
|
+ #### procedure Indent();
|
||||||
|
|
||||||
|
Procedure for add ident to all next strings.
|
||||||
|
|
||||||
|
+ #### procedure UnIndent();
|
||||||
|
|
||||||
|
Procedure for remove ident from all next strings.
|
||||||
|
|
||||||
|
+ #### procedure Write(const Text:string;o:TObject=nil);
|
||||||
|
|
||||||
|
Write string in log.
|
||||||
|
|
||||||
|
+ #### property IndentText:string;
|
||||||
|
|
||||||
|
String what using as indent symbol in log string. Default is DefOneTabStr const(two spaces).
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGRamLog
|
||||||
|
|
||||||
|
Write log in RAM buffer.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### buf:String;
|
||||||
|
|
||||||
|
Buffer when you can find log.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGDiskLog
|
||||||
|
|
||||||
|
File log.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### constructor Create(const FileName:String);
|
||||||
|
|
||||||
|
Use to create log from file name. If file not exist if will created.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGNullLog
|
||||||
|
|
||||||
|
Use if you don't need log, but don't want del logging from code.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGCommandLineLog
|
||||||
|
|
||||||
|
Write log to command line.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### constructor Create(Handele:THandle);
|
||||||
|
|
||||||
|
Use to create log from winapi handle. Use as:
|
||||||
|
|
||||||
|
`Log:=TAGCommandLineLog.Create(GetStdHandle(STD_OUTPUT_HANDLE));`
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGStreamLog
|
||||||
|
|
||||||
|
Write log to pascal stream.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### constructor Create(Astream:TStream);
|
||||||
|
|
||||||
|
Use to create log from pascal stream.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGCallBackLog
|
||||||
|
|
||||||
|
Write log to callback.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### TCallBack
|
||||||
|
|
||||||
|
Type. In delphi it is anonimus procedure, in free pascal - standart procedure. Declaration:
|
||||||
|
|
||||||
|
`TCallBack={$IFNDEF FPC}reference to{$ENDIF}procedure(s:string);`
|
||||||
|
|
||||||
|
+ #### constructor Create(ACallBack:TCallBack);
|
||||||
|
|
||||||
|
Use to create log from callback.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
## TAGMultiLog
|
||||||
|
|
||||||
|
Write all to other logs.
|
||||||
|
|
||||||
|
### public metods & propertys
|
||||||
|
|
||||||
|
+ #### TLogsList
|
||||||
|
|
||||||
|
Type for list of logs. In delphi it is `System.Generics.Collections.TList`, in free pascal - `FGL.TFPGList`. Declaration:
|
||||||
|
|
||||||
|
`TLogsList={$IFDEF FPC}specialize TFPGList<TAGLog>{$ELSE}TList<TAGLog>{$ENDIF}`
|
||||||
|
|
||||||
|
+ #### constructor Create(ALogs:TLogsList);
|
||||||
|
|
||||||
|
Use to create log from TLogsList. If ALogs is nil.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user