diff --git a/AG.Logs.pas b/AG.Logs.pas index 65777f6..5136f04 100644 --- a/AG.Logs.pas +++ b/AG.Logs.pas @@ -1,7 +1,7 @@ //**************************************************** -//*Copyright (c) 2018 Artem Gavrilov * -//*Website: https://teamfnd.ru * -//*License: MIT * +//*Copyright (c) 2018 Artem Gavrilov * +//*Website: https://teamfnd.ru * +//*License: MIT * //*Donate: https://money.yandex.ru/to/410014959153552* //**************************************************** unit AG.Logs; @@ -58,14 +58,14 @@ type ThreadID:cardinal; Lock:TCriticalSection; WantTerminate:Boolean; - {$ELSE} + {$ELSE} Stream:TStream; {$ENDIF} - public - constructor Create(const FileName:String);overload; {$IF defined(MSWINDOWS) and not defined(FPC)} procedure Init();stdcall; {$ENDIF} + public + constructor Create(const FileName:String);overload; procedure Write(const Text:string;o:TObject=nil);overload;override; destructor Destroy();overload;override; end; @@ -99,7 +99,7 @@ type strict protected type TCallBack={$IFNDEF FPC}reference to{$ENDIF}procedure(s:string); var - CallBack:TCallBack; + CallBack:TCallBack; public constructor Create(ACallBack:TCallBack);overload; procedure Write(const Text:string;o:TObject=nil);overload;override; @@ -110,10 +110,10 @@ type procedure SetIndentText(const s:string);override; public type - TLogsList={$IFDEF FPC}specialize TFPGList{$ELSE}TList{$ENDIF}; + TLogsList={$IFDEF FPC}specialize TFPGList{$ELSE}TList{$ENDIF}; var - Logs:TLogsList; - constructor Create(Default:TLogsList);overload; + Logs:TLogsList; + constructor Create(ALogs:TLogsList=nil);overload; procedure Write(const Text:string;o:TObject=nil);overload;override; procedure Indent();override; procedure UnIndent();override; @@ -406,11 +406,11 @@ for i in Logs do i.IndentText:=s; end; -constructor TAGMultiLog.Create(Default:TLogsList); +constructor TAGMultiLog.Create(ALogs:TLogsList=nil); begin //inherited Create; if Default<>nil then - Logs:=Default + Logs:=ALogs else Logs:=TLogsList.Create; end; diff --git a/DOC_EN.MD b/DOC_EN.MD new file mode 100644 index 0000000..08636f2 --- /dev/null +++ b/DOC_EN.MD @@ -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{$ELSE}TList{$ENDIF}` + ++ #### constructor Create(ALogs:TLogsList); + + Use to create log from TLogsList. If ALogs is nil. + + + + diff --git a/DOC_RU.MD b/DOC_RU.MD new file mode 100644 index 0000000..08636f2 --- /dev/null +++ b/DOC_RU.MD @@ -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{$ELSE}TList{$ENDIF}` + ++ #### constructor Create(ALogs:TLogsList); + + Use to create log from TLogsList. If ALogs is nil. + + + +