From 7aef2d3b8847c96e32e5f6c94b7cca69bcffe1ec Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Wed, 3 Apr 2024 18:42:32 +0200 Subject: [PATCH] Squashed 'lib/loggerpro/' changes from d490578b..b4faeb63 b4faeb63 Added DBAppenderFireDAC sample. Small cleans to the code. b0309600 Merge pull request #89 from fastbike/v2.0 80b27d35 Added DB logging appenders: FireDAC and dbGo (ADO). Includes a sample app using dbGO 08ae6ac0 Removed inline variable declaration to mantain compatibility with older delphi versions 1c4a6686 Merge remote-tracking branch 'origin/master' into v2.0 bf750989 Updated copyright a94123c0 Added vertual method TLoggerProConsoleAppender.SetupColorMappings to customize colors in descendants 2a54eae4 Merge pull request #86 from TommiPrami/Typos 4bac0b9c Grammar fixed 2c447d5f Tiny Typos fixed git-subtree-dir: lib/loggerpro git-subtree-split: b4faeb63360010e36423d747949f4d378d659054 --- LoggerPro.ConsoleAppender.pas | 50 +- LoggerPro.DBAppender.ADO.pas | 85 ++ LoggerPro.DBAppender.FireDAC.pas | 39 + LoggerPro.DBAppender.pas | 142 +++ LoggerPro.DMSEventStreamsAppender.pas | 2 +- LoggerPro.EMailAppender.pas | 2 +- LoggerPro.ElasticSearchAppender.pas | 2 +- LoggerPro.FileAppender.pas | 2 +- LoggerPro.GlobalLogger.pas | 2 +- LoggerPro.Proxy.pas | 2 +- LoggerPro.RESTAppender.pas | 2 +- LoggerPro.RedisAppender.pas | 2 +- LoggerPro.UDPSyslogAppender.pas | 2 +- LoggerPro.Utils.pas | 2 +- LoggerPro.VCLListBoxAppender.pas | 2 +- LoggerPro.VCLListViewAppender.pas | 2 +- LoggerPro.VCLMemoAppender.pas | 2 +- LoggerPro.WindowsEventLogAppender.pas | 2 +- LoggerPro.pas | 5 +- ThreadSafeQueueU.pas | 2 +- samples/140_DB_appender/ADOAppenderFormU.dfm | 60 + samples/140_DB_appender/ADOAppenderFormU.pas | 92 ++ samples/140_DB_appender/LoggerProConfig.pas | 80 ++ .../140_DB_appender/dbGoAppenderSample.dpr | 16 + .../140_DB_appender/dbGoAppenderSample.dproj | 1096 ++++++++++++++++ samples/140_DB_appender/readme.txt | 10 + .../FDConnectionConfigU.pas | 227 ++++ .../FireDACAppenderFormU.dfm | 60 + .../FireDACAppenderFormU.pas | 92 ++ .../FireDACAppenderSample.delphilsp.json | 1 + .../FireDACAppenderSample.dpr | 19 + .../FireDACAppenderSample.dproj | 1104 +++++++++++++++++ .../LoggerProConfig.pas | 112 ++ .../postgresql_ddl.sql | 27 + .../50_custom_appender/LoggerProConfig.pas | 5 +- 35 files changed, 3314 insertions(+), 38 deletions(-) create mode 100644 LoggerPro.DBAppender.ADO.pas create mode 100644 LoggerPro.DBAppender.FireDAC.pas create mode 100644 LoggerPro.DBAppender.pas create mode 100644 samples/140_DB_appender/ADOAppenderFormU.dfm create mode 100644 samples/140_DB_appender/ADOAppenderFormU.pas create mode 100644 samples/140_DB_appender/LoggerProConfig.pas create mode 100644 samples/140_DB_appender/dbGoAppenderSample.dpr create mode 100644 samples/140_DB_appender/dbGoAppenderSample.dproj create mode 100644 samples/140_DB_appender/readme.txt create mode 100644 samples/150_DB_appender_firedac/FDConnectionConfigU.pas create mode 100644 samples/150_DB_appender_firedac/FireDACAppenderFormU.dfm create mode 100644 samples/150_DB_appender_firedac/FireDACAppenderFormU.pas create mode 100644 samples/150_DB_appender_firedac/FireDACAppenderSample.delphilsp.json create mode 100644 samples/150_DB_appender_firedac/FireDACAppenderSample.dpr create mode 100644 samples/150_DB_appender_firedac/FireDACAppenderSample.dproj create mode 100644 samples/150_DB_appender_firedac/LoggerProConfig.pas create mode 100644 samples/150_DB_appender_firedac/postgresql_ddl.sql diff --git a/LoggerPro.ConsoleAppender.pas b/LoggerPro.ConsoleAppender.pas index 0f9c02cf..e158e6d8 100644 --- a/LoggerPro.ConsoleAppender.pas +++ b/LoggerPro.ConsoleAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // @@ -55,7 +55,10 @@ type class constructor Create; // allocate global vars class destructor Destroy; protected + fColors: array [TLogType.Debug .. TLogType.Fatal] of Integer; + fSavedColors: Integer; procedure SetColor(const Color: Integer); + procedure SetupColorMappings; virtual; public procedure Setup; override; procedure TearDown; override; @@ -95,6 +98,17 @@ begin SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), Color); end; +function GetCurrentColors: Integer; +var + info: CONSOLE_SCREEN_BUFFER_INFO; +begin + Result := -1; + if GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), info) then + begin + Result := info.wAttributes; + end; +end; + procedure TLoggerProConsoleAppender.Setup; begin inherited; @@ -104,12 +118,16 @@ begin try if TInterlocked.Increment(TLoggerProConsoleAppender.FConsoleAllocated) = 1 then begin + SetupColorMappings; // Attempt to attach to the parent (if there is already a console allocated) if not IsConsole then begin if not AttachConsole(ATTACH_PARENT_PROCESS) then + begin AllocConsole; // No console allocated, create a new one + end; end; + fSavedColors := GetCurrentColors; TInterlocked.Increment(TLoggerProConsoleAppender.FConsoleAllocated); end; finally @@ -118,9 +136,21 @@ begin end; end; +procedure TLoggerProConsoleAppender.SetupColorMappings; +begin + fColors[TLogType.Debug] := FOREGROUND_GREEN; + fColors[TLogType.Info] := FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED; + fColors[TLogType.Warning] := FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_INTENSITY; + fColors[TLogType.Error] := FOREGROUND_RED or FOREGROUND_INTENSITY; + fColors[TLogType.Fatal] := FOREGROUND_RED or FOREGROUND_BLUE or FOREGROUND_INTENSITY; +end; + procedure TLoggerProConsoleAppender.TearDown; begin - + if fSavedColors > -1 then + SetColor(fSavedColors) + else + SetColor(FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED); end; procedure TLoggerProConsoleAppender.WriteLog(const aLogItem: TLogItem); @@ -128,22 +158,8 @@ var lText: string; lColor: Integer; begin - lColor := FOREGROUND_GREEN; // Avoid W1030 - case aLogItem.LogType of - TLogType.Debug: - lColor := FOREGROUND_GREEN; - TLogType.Info: - lColor := FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED; - TLogType.Warning: - lColor := FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_INTENSITY; - TLogType.Error: - lColor := FOREGROUND_RED or FOREGROUND_INTENSITY; - TLogType.Fatal: - lColor := FOREGROUND_RED or FOREGROUND_BLUE or FOREGROUND_INTENSITY; - end; - + lColor := fColors[aLogItem.LogType]; lText := FormatLog(aLogItem); - TLoggerProConsoleAppender.FLock.Enter; try SetColor(lColor); diff --git a/LoggerPro.DBAppender.ADO.pas b/LoggerPro.DBAppender.ADO.pas new file mode 100644 index 00000000..53ef2a0b --- /dev/null +++ b/LoggerPro.DBAppender.ADO.pas @@ -0,0 +1,85 @@ +unit LoggerPro.DBAppender.ADO; + +// DB log appender - using dbGo aka ADO + +interface + +uses + System.Classes, + LoggerPro, System.SysUtils, Data.DB, + LoggerPro.DBAppender, + Data.Win.ADODB; + +type + ESQLException = class(Exception) + private + FErrorCode: Integer; + public + constructor Create(AMessage: string; AErrorCode: Integer); overload; + constructor Create(StoredProc: TADOStoredProc); overload; + end; + + /// LoggerPro that persists to DB via ADO stored procedure + TLoggerProDBAppenderADO = class(TLoggerProDBAppender) + protected + procedure RefreshParams(DataObj: TADOStoredProc); override; + procedure ExecuteDataObject(DataObj: TADOStoredProc); override; + public + procedure Setup; override; + procedure TearDown; override; + end; + +implementation + +uses + System.IOUtils, Winapi.ActiveX; + +{ ESQLException } + +constructor ESQLException.Create(AMessage: string; AErrorCode: Integer); +begin + inherited Create(AMessage); + FErrorCode := AErrorCode; +end; + +constructor ESQLException.Create(StoredProc: TADOStoredProc); +var + LastErrorIdx: Integer; +begin + if StoredProc.Connection <> nil then + begin + LastErrorIdx := StoredProc.Connection.Errors.Count - 1; + Create(StoredProc.Connection.Errors.Item[LastErrorIdx].Description, StoredProc.Connection.Errors.Item[LastErrorIdx] + .NativeError); + end; +end; + +{ TLoggerProDBAppenderADO } + +procedure TLoggerProDBAppenderADO.ExecuteDataObject(DataObj: TADOStoredProc); +begin + DataObj.ExecProc; + + if DataObj.Connection.Errors.Count > 0 then + raise ESQLException.Create(DataObj); +end; + +procedure TLoggerProDBAppenderADO.RefreshParams(DataObj: TADOStoredProc); +begin + DataObj.Parameters.Refresh; +end; + +procedure TLoggerProDBAppenderADO.Setup; +begin + CoInitialize(nil); + inherited; +end; + +procedure TLoggerProDBAppenderADO.TearDown; +begin + inherited; + CoUninitialize; +end; + + +end. diff --git a/LoggerPro.DBAppender.FireDAC.pas b/LoggerPro.DBAppender.FireDAC.pas new file mode 100644 index 00000000..f2f83b5e --- /dev/null +++ b/LoggerPro.DBAppender.FireDAC.pas @@ -0,0 +1,39 @@ +unit LoggerPro.DBAppender.FireDAC; + +// DB log appender for FireDAC + +interface + +uses + System.Classes, + LoggerPro, System.SysUtils, Data.DB, + LoggerPro.DBAppender, + FireDAC.Stan.Error, + FireDAC.DApt, + FireDAC.Phys, + FireDAC.Stan.Param, + FireDAC.Comp.Client; + +type + /// LoggerPro that persists to DB via a FireDAC stored procedure + TLoggerProDBAppenderFireDAC = class(TLoggerProDBAppender) + protected + procedure RefreshParams(DataObj: TFDStoredProc); override; + procedure ExecuteDataObject(DataObj: TFDStoredProc); override; + end; + +implementation + +{ TLoggerProDBAppenderFireDAC } + +procedure TLoggerProDBAppenderFireDAC.ExecuteDataObject(DataObj: TFDStoredProc); +begin + DataObj.ExecProc; +end; + +procedure TLoggerProDBAppenderFireDAC.RefreshParams(DataObj: TFDStoredProc); +begin + DataObj.Prepare; +end; + +end. diff --git a/LoggerPro.DBAppender.pas b/LoggerPro.DBAppender.pas new file mode 100644 index 00000000..9d49c665 --- /dev/null +++ b/LoggerPro.DBAppender.pas @@ -0,0 +1,142 @@ +unit LoggerPro.DBAppender; + +// Abstract LoggerPro Appender that writes to a database +// Subclass to use with DB connection stack of choice e.g. ADO, FireDAC etc +// only supports parameterised stored procedures for security and performance + +interface + +uses + System.Classes, LoggerPro, System.SysUtils, Data.DB; + +type + TOnDBWriteError = reference to procedure(const Sender: TObject; const LogItem: TLogItem; const DBError: Exception; + var RetryCount: Integer); + + TGetDBConnection = reference to function: TCustomConnection; + + TGetStoredProc = reference to function(Connection: TCustomConnection): T; + + TSetParams = reference to procedure(DataObject: T; LogItem: TLogItem); + + + ///Abstract class for writing logs to database + /// Subclass with your choice of stored procedure class to get a working logger + TLoggerProDBAppender = class(TLoggerProAppenderBase) + protected + const MAX_RETRY_COUNT = 5; + protected + FOnDBWriteError: TOnDBWriteError; + FGetDBConnection: TGetDBConnection; + FGetStoredProc: TGetStoredProc; + FSetParams: TSetParams; + + FDBConnection: TCustomConnection; + FDBObject: T; + procedure RefreshParams(DataObj: T); virtual; abstract; + procedure ExecuteDataObject(DataObj: T); virtual; abstract; + public + constructor Create(GetDBConnection: TGetDBConnection; GetStoredProc: TGetStoredProc; SetParams: TSetParams; + OnDBWriteError: TOnDBWriteError); reintroduce; + procedure Setup; override; + procedure TearDown; override; + procedure TryToRestart(var Restarted: Boolean); override; + procedure WriteLog(const ALogItem: TLogItem); override; + end; + +implementation + +{ TLoggerProDBAppender } + +///Create an instance of the DB logger +/// anonymous function that returns a configured DB Connection +/// anonymous function that returns a stored proc that can write to the DB +/// anonymous procedure that populates parameters before the stored proc is executed +/// anonymous procedure to handle retry of a failed operaation +constructor TLoggerProDBAppender.Create(GetDBConnection: TGetDBConnection; GetStoredProc: TGetStoredProc; + SetParams: TSetParams; OnDBWriteError: TOnDBWriteError); +begin + inherited Create; + FGetDBConnection := GetDBConnection; + FGetStoredProc := GetStoredProc; + FSetParams := SetParams; + FOnDBWriteError := OnDBWriteError; +end; + +procedure TLoggerProDBAppender.Setup; +begin + inherited; + FDBConnection := FGetDBConnection; +end; + +procedure TLoggerProDBAppender.TearDown; +begin + inherited; + if FDBObject <> nil then + FDBObject.Free; + + if FDBConnection <> nil then + begin + FDBConnection.Connected := False; + FDBConnection.Free; + end; +end; + +procedure TLoggerProDBAppender.TryToRestart(var Restarted: Boolean); +begin + try + // remove the DB Object + if FDBObject <> nil then + begin + FDBObject.Free; + FDBObject := nil; + end; + + // reset the DB connection + if FDBConnection <> nil then + begin + FDBConnection.Connected := False; + FDBConnection.Free; + FDBConnection := nil; + end; + except + // no point catching the exception + end; + + // now try to restart it + FDBConnection := FGetDBConnection; + Restarted := True; +end; + +procedure TLoggerProDBAppender.WriteLog(const ALogItem: TLogItem); +var + RetryCount: Integer; +begin + RetryCount := 0; + repeat + try + if FDBObject = nil then + begin + FDBConnection.Connected := True; //force an exception if needed + FDBObject := FGetStoredProc(FDBConnection); + RefreshParams(FDBObject); //this may not raise unhandled exception even in case of disconnection + end; + FSetParams(FDBObject, ALogItem); + ExecuteDataObject(FDBObject); + Break; + except + on E: Exception do + begin + // if there is an event handler for DB exception, call it + if Assigned(FOnDBWriteError) then + FOnDBWriteError(Self, ALogItem, E, RetryCount); + Inc(RetryCount); + // if the handler has set FRetryCount to a positive value then retry the call + if RetryCount >= MAX_RETRY_COUNT then + raise; + end; + end; + until False; +end; + +end. diff --git a/LoggerPro.DMSEventStreamsAppender.pas b/LoggerPro.DMSEventStreamsAppender.pas index a459d3b4..b919d000 100644 --- a/LoggerPro.DMSEventStreamsAppender.pas +++ b/LoggerPro.DMSEventStreamsAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.EMailAppender.pas b/LoggerPro.EMailAppender.pas index 5d4280c9..8f6a4f30 100644 --- a/LoggerPro.EMailAppender.pas +++ b/LoggerPro.EMailAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.ElasticSearchAppender.pas b/LoggerPro.ElasticSearchAppender.pas index eb7aeb27..2cbbe648 100644 --- a/LoggerPro.ElasticSearchAppender.pas +++ b/LoggerPro.ElasticSearchAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.FileAppender.pas b/LoggerPro.FileAppender.pas index 399931ce..9c450899 100644 --- a/LoggerPro.FileAppender.pas +++ b/LoggerPro.FileAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.GlobalLogger.pas b/LoggerPro.GlobalLogger.pas index ad8da7aa..8d8f9842 100644 --- a/LoggerPro.GlobalLogger.pas +++ b/LoggerPro.GlobalLogger.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.Proxy.pas b/LoggerPro.Proxy.pas index b2c1c130..3dce330c 100644 --- a/LoggerPro.Proxy.pas +++ b/LoggerPro.Proxy.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.RESTAppender.pas b/LoggerPro.RESTAppender.pas index 4cc0eecd..8e8dc28e 100644 --- a/LoggerPro.RESTAppender.pas +++ b/LoggerPro.RESTAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.RedisAppender.pas b/LoggerPro.RedisAppender.pas index 3efd5878..81754078 100644 --- a/LoggerPro.RedisAppender.pas +++ b/LoggerPro.RedisAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.UDPSyslogAppender.pas b/LoggerPro.UDPSyslogAppender.pas index fbcffce1..13cb409c 100644 --- a/LoggerPro.UDPSyslogAppender.pas +++ b/LoggerPro.UDPSyslogAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.Utils.pas b/LoggerPro.Utils.pas index 4a18a0a8..bc52079e 100644 --- a/LoggerPro.Utils.pas +++ b/LoggerPro.Utils.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.VCLListBoxAppender.pas b/LoggerPro.VCLListBoxAppender.pas index 3e5c13a2..c957fce7 100644 --- a/LoggerPro.VCLListBoxAppender.pas +++ b/LoggerPro.VCLListBoxAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.VCLListViewAppender.pas b/LoggerPro.VCLListViewAppender.pas index 4431e0f4..a39e3202 100644 --- a/LoggerPro.VCLListViewAppender.pas +++ b/LoggerPro.VCLListViewAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.VCLMemoAppender.pas b/LoggerPro.VCLMemoAppender.pas index 9914cbe4..9bafb88a 100644 --- a/LoggerPro.VCLMemoAppender.pas +++ b/LoggerPro.VCLMemoAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.WindowsEventLogAppender.pas b/LoggerPro.WindowsEventLogAppender.pas index 40ccaf33..04141ffc 100644 --- a/LoggerPro.WindowsEventLogAppender.pas +++ b/LoggerPro.WindowsEventLogAppender.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/LoggerPro.pas b/LoggerPro.pas index cc64121c..695597a0 100644 --- a/LoggerPro.pas +++ b/LoggerPro.pas @@ -299,11 +299,9 @@ type FEnabled: Boolean; FLastErrorTimeStamp: TDateTime; FOnLogRow: TOnAppenderLogRow; - //FLogFormat: string; FLogItemRenderer: ILogItemRenderer; FFormatSettings: TFormatSettings; protected -// property LogFormat: string read FLogFormat; property FormatSettings: TFormatSettings read FFormatSettings; public constructor Create(ALogItemRenderer: ILogItemRenderer = nil); virtual; @@ -403,6 +401,7 @@ function LogLayoutByPlaceHoldersToLogLayoutByIndexes(const LogLayoutByPlaceHolde var PlaceHolders, PlaceHolderWidthsAndPaddings: TArray; I: Integer; + lIdx: Integer; begin if LogLayoutByPlaceHolders.Contains('%s') or LogLayoutByPlaceHolders.Contains('%d') then begin @@ -440,7 +439,7 @@ begin if UseZeroBasedIncrementalIndexes then begin - var lIdx := 0; + lIdx := 0; for I := 0 to High(PlaceHolders) do begin if Result.Contains('{' + PlaceHolders[I] + '}') then diff --git a/ThreadSafeQueueU.pas b/ThreadSafeQueueU.pas index b08f854a..46dd41ec 100644 --- a/ThreadSafeQueueU.pas +++ b/ThreadSafeQueueU.pas @@ -2,7 +2,7 @@ // // LoggerPro // -// Copyright (c) 2010-2023 Daniele Teti +// Copyright (c) 2010-2024 Daniele Teti // // https://github.com/danieleteti/loggerpro // diff --git a/samples/140_DB_appender/ADOAppenderFormU.dfm b/samples/140_DB_appender/ADOAppenderFormU.dfm new file mode 100644 index 00000000..58d9d9fc --- /dev/null +++ b/samples/140_DB_appender/ADOAppenderFormU.dfm @@ -0,0 +1,60 @@ +object MainForm: TMainForm + Left = 0 + Top = 0 + Caption = 'LoggerPro SAMPLE' + ClientHeight = 142 + ClientWidth = 584 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Visible = True + TextHeight = 13 + object Button1: TButton + Left = 8 + Top = 8 + Width = 137 + Height = 57 + Caption = 'DEBUG' + TabOrder = 0 + OnClick = Button1Click + end + object Button2: TButton + Left = 151 + Top = 8 + Width = 137 + Height = 57 + Caption = 'INFO' + TabOrder = 1 + OnClick = Button2Click + end + object Button3: TButton + Left = 294 + Top = 8 + Width = 137 + Height = 57 + Caption = 'WARNING' + TabOrder = 2 + OnClick = Button3Click + end + object Button4: TButton + Left = 437 + Top = 8 + Width = 137 + Height = 57 + Caption = 'ERROR' + TabOrder = 3 + OnClick = Button4Click + end + object Button5: TButton + Left = 8 + Top = 71 + Width = 280 + Height = 57 + Caption = 'Multithread logging' + TabOrder = 4 + OnClick = Button5Click + end +end diff --git a/samples/140_DB_appender/ADOAppenderFormU.pas b/samples/140_DB_appender/ADOAppenderFormU.pas new file mode 100644 index 00000000..5a37dec4 --- /dev/null +++ b/samples/140_DB_appender/ADOAppenderFormU.pas @@ -0,0 +1,92 @@ +unit ADOAppenderFormU; + +interface + +uses + Winapi.Windows, + Winapi.Messages, + System.SysUtils, + System.Variants, + System.Classes, + Vcl.Graphics, + Vcl.Controls, + Vcl.Forms, + Vcl.Dialogs, + Vcl.StdCtrls, + LoggerPro, + Vcl.ExtCtrls; + +type + TMainForm = class(TForm) + Button1: TButton; + Button2: TButton; + Button3: TButton; + Button4: TButton; + Button5: TButton; + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + procedure Button3Click(Sender: TObject); + procedure Button4Click(Sender: TObject); + procedure Button5Click(Sender: TObject); + private + { Private declarations } + public + + end; + +var + MainForm: TMainForm; + +implementation + +{$R *.dfm} + +uses + LoggerProConfig; + +procedure TMainForm.Button1Click(Sender: TObject); +begin + Log.Debug('This is a debug message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button2Click(Sender: TObject); +begin + Log.Info('This is a info message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button3Click(Sender: TObject); +begin + Log.Warn('This is a warning message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button4Click(Sender: TObject); +begin + Log.Error('This is a error message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button5Click(Sender: TObject); +var + lThreadProc: TProc; +begin + lThreadProc := procedure + var + I: Integer; + lThreadID: string; + begin + lThreadID := IntToStr(TThread.Current.ThreadID); + for I := 1 to 100 do + begin + Log.Debug('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Info('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Warn('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Error('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Fatal('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + end; + end; + TThread.CreateAnonymousThread(lThreadProc).Start; + TThread.CreateAnonymousThread(lThreadProc).Start; + TThread.CreateAnonymousThread(lThreadProc).Start; + TThread.CreateAnonymousThread(lThreadProc).Start; +end; + +end. diff --git a/samples/140_DB_appender/LoggerProConfig.pas b/samples/140_DB_appender/LoggerProConfig.pas new file mode 100644 index 00000000..5a5448a0 --- /dev/null +++ b/samples/140_DB_appender/LoggerProConfig.pas @@ -0,0 +1,80 @@ +unit LoggerProConfig; + +// instantiate and call the Logging appender that writes to the Logging database + +interface + +uses + LoggerPro; + +///global function pointer tha returns a DB Logger instance +var + Log: function: ILogWriter; + +implementation + +uses + System.SysUtils, + System.Classes, + LoggerPro.DBAppender.ADO, + Data.DB, Data.Win.ADODB, + System.IOUtils, + Winapi.ActiveX, System.NetEncoding; + +var + _Log: ILogWriter; + +const + FailedDBWriteTag = 'FailedDBWrite'; + +function GetLogger: ILogWriter; +begin + + if _Log = nil then + begin + _Log := BuildLogWriter([TLoggerProDBAppenderADO.Create( + // create an ADO DB Connection + function: TCustomConnection + begin + Result := TADOConnection.Create(nil); + Result.LoginPrompt := False; + // todo: set the connection string in here, typically read from env variables or config file + TADOConnection(Result).ConnectionString := ''; + end, + // create a stored proc + function(Connection: TCustomConnection): TADOStoredProc + begin + Result := TADOStoredProc.Create(nil); + Result.ProcedureName := 'todo: set the stored proc name here'; + Result.Connection := Connection as TADOConnection; + end, + // populate the stored proc + procedure(SP: TADOStoredProc; LogItem: TLogItem) + begin + SP.Parameters.ParamByName('@LogType').Value := Integer(LogItem.LogType); + SP.Parameters.ParamByName('@LogTag').Value := LogItem.LogTag; + SP.Parameters.ParamByName('@LogMessage').Value := LogItem.LogMessage; + SP.Parameters.ParamByName('@Timestamp').Value := LogItem.TimeStamp; + SP.Parameters.ParamByName('@TID').Value := LogItem.ThreadID; + end, + // error handler, just write to disk on the server for later analysis + procedure(const Sender: TObject; const LogItem: TLogItem; const DBError: Exception; var RetryCount: Integer) + begin + // write code in here to write out using system default logger to a local file + // Log.Error('Could not write Viewer Request: %s', [DBError.Message], FailedDBWriteTag); + // Log.Error('Data: %s', [LogItem.LogMessage], FailedDBWriteTag); + end)]); + + end; + Result := _Log; +end; + +initialization + +Log := GetLogger; + +finalization + +_Log := nil; + +end. diff --git a/samples/140_DB_appender/dbGoAppenderSample.dpr b/samples/140_DB_appender/dbGoAppenderSample.dpr new file mode 100644 index 00000000..49fe56b0 --- /dev/null +++ b/samples/140_DB_appender/dbGoAppenderSample.dpr @@ -0,0 +1,16 @@ +program dbGoAppenderSample; + +uses + Vcl.Forms, + ADOAppenderFormU in 'ADOAppenderFormU.pas' {MainForm}, + LoggerProConfig in 'LoggerProConfig.pas'; + //LoggerPro.RESTAppender in '..\..\LoggerPro.RESTAppender.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. diff --git a/samples/140_DB_appender/dbGoAppenderSample.dproj b/samples/140_DB_appender/dbGoAppenderSample.dproj new file mode 100644 index 00000000..d548657d --- /dev/null +++ b/samples/140_DB_appender/dbGoAppenderSample.dproj @@ -0,0 +1,1096 @@ + + + {6428419F-8F13-4ED8-94A7-2F7860515AAC} + 20.1 + VCL + dbGoAppenderSample.dpr + True + Debug + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + dbGoAppenderSample + $(BDS)\bin\delphi_PROJECTICON.ico + .\$(Platform)\$(Config) + .\$(Platform)\$(Config) + false + false + false + false + false + + + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(ModuleName);FileDescription=$(ModuleName);ProductName=$(ModuleName) + ..\..\;$(DCC_UnitSearchPath) + DBXSqliteDriver;DBXDb2Driver;dxCoreRS23;vclactnband;frxe23;vclFireDAC;dxPSLnksRS23;dxPSdxLCLnkRS23;tethering;cxDataRS23;dxPSdxOCLnkRS23;dxTabbedMDIRS23;FireDACADSDriver;dxSkinBlackRS23;dxSkinLondonLiquidSkyRS23;JvPluginSystem;dxDBXServerModeRS23;dxHttpIndyRequestRS23;dxPScxGridLnkRS23;cxSchedulerRS23;FireDACMSSQLDriver;dclRBDBE1723;vcltouch;JvBands;vcldb;rbDB1723;svn;dxWizardControlRS23;dxSkinMcSkinRS23;dxPScxCommonRS23;JvJans;Intraweb;dxSkinOffice2007BlueRS23;rbIBE1723;dxBarRS23;cxSchedulerRibbonStyleEventEditorRS23;dxSkinOffice2013WhiteRS23;JvDotNetCtrls;dxPSTeeChartRS23;cxLibraryRS23;dxSkinVisualStudio2013LightRS23;vclib;cxPivotGridChartRS23;rbDBE1723;dxSkinSummer2008RS23;dxPSdxDBOCLnkRS23;dxGDIPlusRS23;dxSkinDarkSideRS23;FireDACDBXDriver;dxSkinFoggyRS23;dxSkinSevenRS23;vclx;rbCIDE1723;dxSkinOffice2010SilverRS23;dxdborRS23;RESTBackendComponents;dxLayoutControlRS23;dxPSPrVwRibbonRS23;VCLRESTComponents;dxSkinDevExpressStyleRS23;dxSkinWhiteprintRS23;vclie;bindengine;CloudService;rbRAP1723;JvHMI;FireDACMySQLDriver;dxSkinOffice2013DarkGrayRS23;DataSnapClient;dxPScxPCProdRS23;bindcompdbx;DBXSybaseASEDriver;IndyIPServer;dxSkinPumpkinRS23;IndySystem;dsnapcon;cxTreeListdxBarPopupMenuRS23;dclRBIBE1723;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;dxSkinLilianRS23;Jcl;rbADO1723;dxBarDBNavRS23;dxFlowChartRS23;dxSkinOffice2016ColorfulRS23;rbUSER1723;DBXOdbcDriver;FireDACTDataDriver;FMXTee;ipstudiowinclient;soaprtl;DbxCommonDriver;dxSpreadSheetRS23;AsyncProDR;JvManagedThreads;dxSkinOffice2007PinkRS23;dxPSdxSpreadSheetLnkRS23;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;DTKANPRPackage;dxSkinHighContrastRS23;rtl;dxSkinSevenClassicRS23;DbxClientDriver;dxSkinDevExpressDarkStyleRS23;DBXSybaseASADriver;dxNavBarRS23;dxSkinMetropolisDarkRS23;CodeSiteExpressPkg;dxSkinTheAsphaltWorldRS23;JvSystem;SampleListViewMultiDetailAppearancePackage;dxRichEditControlRS23;JvStdCtrls;JvTimeFramework;ipstudiowin;appanalytics;cxPivotGridRS23;rbUSERDesign1723;dxSkinsdxDLPainterRS23;IndyIPClient;dxRibbonRS23;dxPScxVGridLnkRS23;bindcompvcl;frxDB23;vcldbx;dxSkinOffice2007SilverRS23;dxPScxTLLnkRS23;dxMapControlRS23;TeeUI;rbDIDE1723;JvPascalInterpreter;JvDocking;VclSmp;dxPScxSchedulerLnkRS23;cxTreeListRS23;FireDACODBCDriver;JclVcl;DataSnapIndy10ServerTransport;dxRibbonCustomizationFormRS23;dxPSRichEditControlLnkRS23;dxBarExtDBItemsRS23;DataSnapProviderClient;FireDACMongoDBDriver;dxSkiniMaginaryRS23;frx23;dxSpellCheckerRS23;JvControls;dxSkinsdxBarPainterRS23;JvPrintPreview;dxSkinCoffeeRS23;DataSnapServerMidas;RESTComponents;DBXInterBaseDriver;rbRTL1723;dxADOServerModeRS23;emsclientfiredac;DataSnapFireDAC;svnui;dxmdsRS23;dxSkinLiquidSkyRS23;dxdbtrRS23;dxSkinSpringTimeRS23;dxPSDBTeeChartRS23;JvGlobus;HOAsysR;dxSkinscxPCPainterRS23;dxPSCoreRS23;DBXMSSQLDriver;JvMM;dxSkinXmas2008BlueRS23;rbDAD1723;DatasnapConnectorsFreePascal;bindcompfmx;JvNet;DBXOracleDriver;dxSkinSilverRS23;dxSkinValentineRS23;inetdb;JvAppFrm;ipstudiowinwordxp;rbTC1723;FmxTeeUI;dxBarExtItemsRS23;FireDACIBDriver;fmx;fmxdae;DelphiCookbookListViewAppearance;dxServerModeRS23;dxPsPrVwAdvRS23;dxSkinOffice2010BlackRS23;JvWizards;cxPageControlRS23;dxSkinStardustRS23;cxSchedulerGridRS23;dbexpress;IndyCore;dxSkinSharpPlusRS23;UIBD21Win32R;JvPageComps;dsnap;DataSnapCommon;emsclient;FireDACCommon;dxSkinOffice2010BlueRS23;bdertl;JvDB;dxSkinVS2010RS23;dxSkinMetropolisRS23;DataSnapConnectors;cxVerticalGridRS23;soapserver;dxSkinCaramelRS23;frxTee23;dxTileControlRS23;JclDeveloperTools;cxGridRS23;CPortLibDXE;FireDACOracleDriver;DBXMySQLDriver;JvCmp;rbFireDAC1723;DBXFirebirdDriver;FireDACCommonDriver;rbTCUI1723;LockBoxDR;inet;IndyIPCommon;JvCustom;dxSkinDarkRoomRS23;dxDockingRS23;vcl;dxSkinOffice2007GreenRS23;dxPScxExtCommonRS23;JvXPCtrls;dxSkinsCoreRS23;FireDACDb2Driver;dxThemeRS23;dxSkinsdxRibbonPainterRS23;dxSkinVisualStudio2013BlueRS23;rbRest1723;TSG5201;dxSkinMoneyTwinsRS23;dxPSdxFCLnkRS23;dxtrmdRS23;TeeDB;FireDAC;cxSchedulerTreeBrowserRS23;JvCore;dxFireDACServerModeRS23;dxSkinBlueRS23;OverbyteIcsD10SRun;JvCrypt;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;cxEditorsRS23;dxSkinGlassOceansRS23;JvDlgs;JvRuntimeDesign;dxSkinsdxNavBarPainterRS23;dxGaugeControlRS23;ibxpress;Tee;dxSkinSharpRS23;DataSnapServer;ibxbindings;cxPivotGridOLAPRS23;rbIDE1723;vclwinx;FireDACDSDriver;dxSkinBlueprintRS23;dxSkinOffice2007BlackRS23;CustomIPTransport;vcldsnap;rbBDE1723;dxSkinOffice2013LightGrayRS23;bindcomp;DBXInformixDriver;officeXPrt;dxPSdxGaugeControlLnkRS23;dxPScxPivotGridLnkRS23;dxorgcRS23;dxPSdxDBTVLnkRS23;dclRBADO1723;vclribbon;dbxcds;KernowSoftwareFMX;adortl;dclRBFireDAC1723;dclRBE1723;dxComnRS23;dsnapxml;dbrtl;inetdbxpress;IndyProtocols;cxExportRS23;dxSkinOffice2016DarkRS23;JclContainers;dxSkinVisualStudio2013DarkRS23;rbRCL1723;dxSkinscxSchedulerPainterRS23;rbRIDE1723;fmxase;$(DCC_UsePackage) + $(BDS)\bin\default_app.manifest + true + 1033 + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + + + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + DBXSqliteDriver;DBXDb2Driver;dxCoreRS23;vclactnband;vclFireDAC;dxPSLnksRS23;dxPSdxLCLnkRS23;tethering;cxDataRS23;dxPSdxOCLnkRS23;dxTabbedMDIRS23;FireDACADSDriver;dxSkinBlackRS23;dxSkinLondonLiquidSkyRS23;dxDBXServerModeRS23;dxHttpIndyRequestRS23;dxPScxGridLnkRS23;cxSchedulerRS23;FireDACMSSQLDriver;vcltouch;vcldb;dxWizardControlRS23;dxSkinMcSkinRS23;dxPScxCommonRS23;Intraweb;dxSkinOffice2007BlueRS23;dxBarRS23;cxSchedulerRibbonStyleEventEditorRS23;dxSkinOffice2013WhiteRS23;dxPSTeeChartRS23;cxLibraryRS23;dxSkinVisualStudio2013LightRS23;vclib;cxPivotGridChartRS23;dxSkinSummer2008RS23;dxPSdxDBOCLnkRS23;dxGDIPlusRS23;dxSkinDarkSideRS23;FireDACDBXDriver;dxSkinFoggyRS23;dxSkinSevenRS23;vclx;dxSkinOffice2010SilverRS23;dxdborRS23;RESTBackendComponents;dxLayoutControlRS23;dxPSPrVwRibbonRS23;VCLRESTComponents;dxSkinDevExpressStyleRS23;dxSkinWhiteprintRS23;vclie;bindengine;CloudService;FireDACMySQLDriver;dxSkinOffice2013DarkGrayRS23;DataSnapClient;dxPScxPCProdRS23;bindcompdbx;DBXSybaseASEDriver;IndyIPServer;dxSkinPumpkinRS23;IndySystem;dsnapcon;cxTreeListdxBarPopupMenuRS23;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;dxSkinLilianRS23;dxBarDBNavRS23;dxFlowChartRS23;dxSkinOffice2016ColorfulRS23;DBXOdbcDriver;FireDACTDataDriver;FMXTee;ipstudiowinclient;soaprtl;DbxCommonDriver;dxSpreadSheetRS23;AsyncProDR;dxSkinOffice2007PinkRS23;dxPSdxSpreadSheetLnkRS23;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;dxSkinHighContrastRS23;rtl;dxSkinSevenClassicRS23;DbxClientDriver;dxSkinDevExpressDarkStyleRS23;DBXSybaseASADriver;dxNavBarRS23;dxSkinMetropolisDarkRS23;dxSkinTheAsphaltWorldRS23;dxRichEditControlRS23;ipstudiowin;appanalytics;cxPivotGridRS23;dxSkinsdxDLPainterRS23;IndyIPClient;dxRibbonRS23;dxPScxVGridLnkRS23;bindcompvcl;dxSkinOffice2007SilverRS23;dxPScxTLLnkRS23;dxMapControlRS23;TeeUI;VclSmp;dxPScxSchedulerLnkRS23;cxTreeListRS23;FireDACODBCDriver;DataSnapIndy10ServerTransport;dxRibbonCustomizationFormRS23;dxPSRichEditControlLnkRS23;dxBarExtDBItemsRS23;DataSnapProviderClient;FireDACMongoDBDriver;dxSkiniMaginaryRS23;dxSpellCheckerRS23;dxSkinsdxBarPainterRS23;dxSkinCoffeeRS23;DataSnapServerMidas;RESTComponents;DBXInterBaseDriver;dxADOServerModeRS23;emsclientfiredac;DataSnapFireDAC;dxmdsRS23;dxSkinLiquidSkyRS23;dxdbtrRS23;dxSkinSpringTimeRS23;dxPSDBTeeChartRS23;dxSkinscxPCPainterRS23;dxPSCoreRS23;DBXMSSQLDriver;dxSkinXmas2008BlueRS23;DatasnapConnectorsFreePascal;bindcompfmx;DBXOracleDriver;dxSkinSilverRS23;dxSkinValentineRS23;inetdb;FmxTeeUI;dxBarExtItemsRS23;FireDACIBDriver;fmx;fmxdae;dxServerModeRS23;dxPsPrVwAdvRS23;dxSkinOffice2010BlackRS23;cxPageControlRS23;dxSkinStardustRS23;cxSchedulerGridRS23;dbexpress;IndyCore;dxSkinSharpPlusRS23;dsnap;DataSnapCommon;emsclient;FireDACCommon;dxSkinOffice2010BlueRS23;dxSkinVS2010RS23;dxSkinMetropolisRS23;DataSnapConnectors;cxVerticalGridRS23;soapserver;dxSkinCaramelRS23;dxTileControlRS23;cxGridRS23;FireDACOracleDriver;DBXMySQLDriver;DBXFirebirdDriver;FireDACCommonDriver;LockBoxDR;inet;IndyIPCommon;dxSkinDarkRoomRS23;dxDockingRS23;vcl;dxSkinOffice2007GreenRS23;dxPScxExtCommonRS23;dxSkinsCoreRS23;FireDACDb2Driver;dxThemeRS23;dxSkinsdxRibbonPainterRS23;dxSkinVisualStudio2013BlueRS23;dxSkinMoneyTwinsRS23;dxPSdxFCLnkRS23;dxtrmdRS23;TeeDB;FireDAC;cxSchedulerTreeBrowserRS23;dxFireDACServerModeRS23;dxSkinBlueRS23;OverbyteIcsD10SRun;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;cxEditorsRS23;dxSkinGlassOceansRS23;dxSkinsdxNavBarPainterRS23;dxGaugeControlRS23;ibxpress;Tee;dxSkinSharpRS23;DataSnapServer;ibxbindings;cxPivotGridOLAPRS23;vclwinx;FireDACDSDriver;dxSkinBlueprintRS23;dxSkinOffice2007BlackRS23;CustomIPTransport;vcldsnap;dxSkinOffice2013LightGrayRS23;bindcomp;DBXInformixDriver;officeXPrt;dxPSdxGaugeControlLnkRS23;dxPScxPivotGridLnkRS23;dxorgcRS23;dxPSdxDBTVLnkRS23;vclribbon;dbxcds;adortl;dxComnRS23;dsnapxml;dbrtl;inetdbxpress;IndyProtocols;cxExportRS23;dxSkinOffice2016DarkRS23;dxSkinVisualStudio2013DarkRS23;dxSkinscxSchedulerPainterRS23;fmxase;$(DCC_UsePackage) + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + Debug + 1033 + true + true + false + PerMonitor + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + PerMonitor + + + + MainSource + + +
MainForm
+
+ + + Base + + + Cfg_1 + Base + + + Cfg_2 + Base + +
+ + Delphi.Personality.12 + Application + + + + dbGoAppenderSample.dpr + + + Embarcadero C++Builder Office 2000 Servers Package + Embarcadero C++Builder Office XP Servers Package + Microsoft Office 2000 Sample Automation Server Wrapper Components + + + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + classes + 64 + + + classes + 64 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v21 + 1 + + + res\drawable-anydpi-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values-v31 + 1 + + + res\values-v31 + 1 + + + + + res\drawable-anydpi-v26 + 1 + + + res\drawable-anydpi-v26 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v33 + 1 + + + res\drawable-anydpi-v33 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-night-v21 + 1 + + + res\values-night-v21 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable-anydpi-v24 + 1 + + + res\drawable-anydpi-v24 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-night-anydpi-v21 + 1 + + + res\drawable-night-anydpi-v21 + 1 + + + + + res\drawable-anydpi-v31 + 1 + + + res\drawable-anydpi-v31 + 1 + + + + + res\drawable-night-anydpi-v31 + 1 + + + res\drawable-night-anydpi-v31 + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + ..\ + 1 + + + + + Contents + 1 + + + Contents + 1 + + + Contents + 1 + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen + 64 + + + ..\$(PROJECTNAME).launchscreen + 64 + + + + + 1 + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + + + + + + + + + + + + + True + False + + + 12 + + + + +
diff --git a/samples/140_DB_appender/readme.txt b/samples/140_DB_appender/readme.txt new file mode 100644 index 00000000..5fabeee2 --- /dev/null +++ b/samples/140_DB_appender/readme.txt @@ -0,0 +1,10 @@ +You will need a SQL Server database with a stored procedure that can accept the log item as parameters + +e.g. +@LogType int, +@LogTag nvarchar(25), +@LogMessage nvarchar(4096), +@Timestamp datetime, +@TID int + +You will also need to configure the DB Connection string in the LoggerProConfig unit. \ No newline at end of file diff --git a/samples/150_DB_appender_firedac/FDConnectionConfigU.pas b/samples/150_DB_appender_firedac/FDConnectionConfigU.pas new file mode 100644 index 00000000..624cc4b2 --- /dev/null +++ b/samples/150_DB_appender_firedac/FDConnectionConfigU.pas @@ -0,0 +1,227 @@ +unit FDConnectionConfigU; + +interface + +const + CON_DEF_NAME = 'LoggerProConnectionX'; + +procedure CreateFirebirdPrivateConnDef(AIsPooled: boolean); +procedure CreateInterbasePrivateConnDef(AIsPooled: boolean); +procedure CreateMySQLPrivateConnDef(AIsPooled: boolean); +procedure CreateMSSQLServerPrivateConnDef(AIsPooled: boolean); +procedure CreatePostgresqlPrivateConnDef(AIsPooled: boolean); +procedure CreateSqlitePrivateConnDef(AIsPooled: boolean); + +implementation + +uses + System.Classes, + System.IOUtils, + FireDAC.Comp.Client, + FireDAC.Moni.Base, + FireDAC.Moni.FlatFile, + FireDAC.Stan.Intf, + FireDAC.Phys.PG + ; + + +var + gFlatFileMonitor: TFDMoniFlatFileClientLink = nil; + +procedure CreateMySQLPrivateConnDef(AIsPooled: boolean); +var + LParams: TStringList; +begin + { + docker run --detach --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_ROOT_PASSWORD=root -p 3306:3306 mariadb:latest + } + + LParams := TStringList.Create; + try + LParams.Add('Database=activerecorddb'); + LParams.Add('Protocol=TCPIP'); + LParams.Add('Server=localhost'); + LParams.Add('User_Name=root'); + LParams.Add('Password=root'); + LParams.Add('TinyIntFormat=Boolean'); { it's the default } + LParams.Add('CharacterSet=utf8mb4'); // not utf8!! + LParams.Add('MonitorBy=FlatFile'); + if AIsPooled then + begin + LParams.Add('Pooled=True'); + LParams.Add('POOL_MaximumItems=100'); + end + else + begin + LParams.Add('Pooled=False'); + end; + FDManager.AddConnectionDef(CON_DEF_NAME, 'MySQL', LParams); + finally + LParams.Free; + end; +end; + +procedure CreateMSSQLServerPrivateConnDef(AIsPooled: boolean); +var + LParams: TStringList; +begin + { + docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=!SA_password!" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest + } + + // [ACTIVERECORDB_SQLSERVER] + // Database=activerecorddb + // OSAuthent=Yes + // Server=DANIELETETI\SQLEXPRESS + // DriverID=MSSQL + // + + LParams := TStringList.Create; + try + LParams.Add('Database=activerecorddb'); + LParams.Add('OSAuthent=Yes'); + LParams.Add('Server=DANIELETETI\SQLEXPRESS'); + if AIsPooled then + begin + LParams.Add('Pooled=True'); + LParams.Add('POOL_MaximumItems=100'); + end + else + begin + LParams.Add('Pooled=False'); + end; + FDManager.AddConnectionDef(CON_DEF_NAME, 'MSSQL', LParams); + finally + LParams.Free; + end; +end; + +procedure CreateFirebirdPrivateConnDef(AIsPooled: boolean); +var + LParams: TStringList; +begin + LParams := TStringList.Create; + try + LParams.Add('Database=' + TPath.GetFullPath(TPath.Combine('..\..', + 'data\ACTIVERECORDDB.FDB'))); + LParams.Add('Protocol=TCPIP'); + LParams.Add('Server=localhost'); + LParams.Add('User_Name=sysdba'); + LParams.Add('Password=masterkey'); + LParams.Add('CharacterSet=UTF8'); + if AIsPooled then + begin + LParams.Add('Pooled=True'); + LParams.Add('POOL_MaximumItems=100'); + end + else + begin + LParams.Add('Pooled=False'); + end; + FDManager.AddConnectionDef(CON_DEF_NAME, 'FB', LParams); + finally + LParams.Free; + end; +end; + +procedure CreateInterbasePrivateConnDef(AIsPooled: boolean); +var + LParams: TStringList; +begin + LParams := TStringList.Create; + try + LParams.Add('Database=' + TPath.GetFullPath(TPath.Combine('..\..', + 'data\ACTIVERECORDDB.IB'))); + LParams.Add('Protocol=TCPIP'); + LParams.Add('Server=localhost'); + LParams.Add('User_Name=sysdba'); + LParams.Add('Password=masterkey'); + LParams.Add('CharacterSet=UTF8'); + if AIsPooled then + begin + LParams.Add('Pooled=True'); + LParams.Add('POOL_MaximumItems=100'); + end + else + begin + LParams.Add('Pooled=False'); + end; + FDManager.AddConnectionDef(CON_DEF_NAME, 'IB', LParams); + finally + LParams.Free; + end; +end; + +procedure CreatePostgresqlPrivateConnDef(AIsPooled: boolean); +var + LParams: TStringList; +begin + LParams := TStringList.Create; + try + LParams.Add('Database=activerecorddb'); + LParams.Add('Protocol=TCPIP'); + LParams.Add('Server=localhost'); + LParams.Add('User_Name=postgres'); + LParams.Add('Password=postgres'); + //LParams.Add('MonitorBy=FlatFile'); + + // https://quality.embarcadero.com/browse/RSP-19755?jql=text%20~%20%22firedac%20guid%22 + LParams.Add('GUIDEndian=Big'); + if AIsPooled then + begin + LParams.Add('Pooled=True'); + LParams.Add('POOL_MaximumItems=100'); + end + else + begin + LParams.Add('Pooled=False'); + end; + FDManager.AddConnectionDef(CON_DEF_NAME, 'PG', LParams); + finally + LParams.Free; + end; +end; + +procedure CreateSqlitePrivateConnDef(AIsPooled: boolean); +var + LParams: TStringList; + lFName: string; +begin + LParams := TStringList.Create; + try + lFName := TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), + '..\..\data\activerecorddb.db'); + LParams.Add('Database=' + lFName); + LParams.Add('StringFormat=Unicode'); + if AIsPooled then + begin + LParams.Add('Pooled=True'); + LParams.Add('POOL_MaximumItems=100'); + end + else + begin + LParams.Add('Pooled=False'); + end; + FDManager.AddConnectionDef(CON_DEF_NAME, 'SQLite', LParams); + finally + LParams.Free; + end; +end; + +initialization + +gFlatFileMonitor := TFDMoniFlatFileClientLink.Create(nil); +gFlatFileMonitor.FileColumns := [tiRefNo, tiTime, tiThreadID, tiClassName, tiObjID, tiMsgText]; +gFlatFileMonitor.EventKinds := [ + ekVendor, ekConnConnect, ekLiveCycle, ekError, ekConnTransact, + ekCmdPrepare, ekCmdExecute, ekCmdDataIn, ekCmdDataOut]; +gFlatFileMonitor.ShowTraces := False; +gFlatFileMonitor.FileAppend := False; +gFlatFileMonitor.FileName := TPath.ChangeExtension(ParamStr(0), '.trace.log'); +gFlatFileMonitor.Tracing := True; + +finalization + +gFlatFileMonitor.Free; + +end. diff --git a/samples/150_DB_appender_firedac/FireDACAppenderFormU.dfm b/samples/150_DB_appender_firedac/FireDACAppenderFormU.dfm new file mode 100644 index 00000000..58d9d9fc --- /dev/null +++ b/samples/150_DB_appender_firedac/FireDACAppenderFormU.dfm @@ -0,0 +1,60 @@ +object MainForm: TMainForm + Left = 0 + Top = 0 + Caption = 'LoggerPro SAMPLE' + ClientHeight = 142 + ClientWidth = 584 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Visible = True + TextHeight = 13 + object Button1: TButton + Left = 8 + Top = 8 + Width = 137 + Height = 57 + Caption = 'DEBUG' + TabOrder = 0 + OnClick = Button1Click + end + object Button2: TButton + Left = 151 + Top = 8 + Width = 137 + Height = 57 + Caption = 'INFO' + TabOrder = 1 + OnClick = Button2Click + end + object Button3: TButton + Left = 294 + Top = 8 + Width = 137 + Height = 57 + Caption = 'WARNING' + TabOrder = 2 + OnClick = Button3Click + end + object Button4: TButton + Left = 437 + Top = 8 + Width = 137 + Height = 57 + Caption = 'ERROR' + TabOrder = 3 + OnClick = Button4Click + end + object Button5: TButton + Left = 8 + Top = 71 + Width = 280 + Height = 57 + Caption = 'Multithread logging' + TabOrder = 4 + OnClick = Button5Click + end +end diff --git a/samples/150_DB_appender_firedac/FireDACAppenderFormU.pas b/samples/150_DB_appender_firedac/FireDACAppenderFormU.pas new file mode 100644 index 00000000..a7791b02 --- /dev/null +++ b/samples/150_DB_appender_firedac/FireDACAppenderFormU.pas @@ -0,0 +1,92 @@ +unit FireDACAppenderFormU; + +interface + +uses + Winapi.Windows, + Winapi.Messages, + System.SysUtils, + System.Variants, + System.Classes, + Vcl.Graphics, + Vcl.Controls, + Vcl.Forms, + Vcl.Dialogs, + Vcl.StdCtrls, + LoggerPro, + Vcl.ExtCtrls; + +type + TMainForm = class(TForm) + Button1: TButton; + Button2: TButton; + Button3: TButton; + Button4: TButton; + Button5: TButton; + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + procedure Button3Click(Sender: TObject); + procedure Button4Click(Sender: TObject); + procedure Button5Click(Sender: TObject); + private + { Private declarations } + public + + end; + +var + MainForm: TMainForm; + +implementation + +{$R *.dfm} + +uses + LoggerProConfig; + +procedure TMainForm.Button1Click(Sender: TObject); +begin + Log.Debug('This is a debug message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button2Click(Sender: TObject); +begin + Log.Info('This is a info message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button3Click(Sender: TObject); +begin + Log.Warn('This is a warning message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button4Click(Sender: TObject); +begin + Log.Error('This is a error message with TAG1', 'TAG1'); +end; + +procedure TMainForm.Button5Click(Sender: TObject); +var + lThreadProc: TProc; +begin + lThreadProc := procedure + var + I: Integer; + lThreadID: string; + begin + lThreadID := IntToStr(TThread.Current.ThreadID); + for I := 1 to 100 do + begin + Log.Debug('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Info('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Warn('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Error('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + Log.Fatal('log message %s ThreadID: %s', [TimeToStr(now), lThreadID], 'MULTITHREADING'); + end; + end; + TThread.CreateAnonymousThread(lThreadProc).Start; + TThread.CreateAnonymousThread(lThreadProc).Start; + TThread.CreateAnonymousThread(lThreadProc).Start; + TThread.CreateAnonymousThread(lThreadProc).Start; +end; + +end. diff --git a/samples/150_DB_appender_firedac/FireDACAppenderSample.delphilsp.json b/samples/150_DB_appender_firedac/FireDACAppenderSample.delphilsp.json new file mode 100644 index 00000000..24f8db1a --- /dev/null +++ b/samples/150_DB_appender_firedac/FireDACAppenderSample.delphilsp.json @@ -0,0 +1 @@ +{ "settings": { "project": "file:///C%3A/DEV/loggerpro/samples/150_DB_appender_firedac/FireDACAppenderSample.dpr", "dllname": "dcc32290.dll", "dccOptions": "-$O- -$W+ --no-config -Q -TX.exe -AGenerics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DDEBUG;;FRAMEWORK_VCL -E.\\bin -I\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\lib\\Win32\\debug\";C:\\DLib\\spring4d\\Library\\Delphi12\\Win32\\Debug;..\\..;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\lib\\Win32\\release\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\\Win32\";\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\include\";C:\\DEV\\dmvcframework\\sources;C:\\DEV\\dmvcframework\\lib\\dmustache;C:\\DEV\\dmvcframework\\lib\\loggerpro;C:\\DEV\\dmvcframework\\lib\\swagdoc\\source;C:\\DEV\\dmvcframework\\contrib;\"C:\\Users\\Daniele Teti\\AppData\\Local\\Programs\\TestInsight\\Source\";C:\\DLib\\smcmpnt\\SOURCES;C:\\DLib\\spring4d\\Library\\Delphi12\\Win32\\Debug;C:\\DEV\\dmvcframework\\contrib;C:\\DLib\\sempare-delphi-template-engine\\src;C:\\DEV\\dmvcframework\\lib\\crosssocket;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Net;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Utils;C:\\DEV\\loggerpro -LEC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\Bpl -LNC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\Dcp -NU.\\Win32\\Debug -NSWinapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell; -O..\\..;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\lib\\Win32\\release\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\\Win32\";\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\include\";C:\\DEV\\dmvcframework\\sources;C:\\DEV\\dmvcframework\\lib\\dmustache;C:\\DEV\\dmvcframework\\lib\\loggerpro;C:\\DEV\\dmvcframework\\lib\\swagdoc\\source;C:\\DEV\\dmvcframework\\contrib;\"C:\\Users\\Daniele Teti\\AppData\\Local\\Programs\\TestInsight\\Source\";C:\\DLib\\smcmpnt\\SOURCES;C:\\DLib\\spring4d\\Library\\Delphi12\\Win32\\Debug;C:\\DEV\\dmvcframework\\contrib;C:\\DLib\\sempare-delphi-template-engine\\src;C:\\DEV\\dmvcframework\\lib\\crosssocket;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Net;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Utils;C:\\DEV\\loggerpro -R..\\..;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\lib\\Win32\\release\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\\Win32\";\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\include\";C:\\DEV\\dmvcframework\\sources;C:\\DEV\\dmvcframework\\lib\\dmustache;C:\\DEV\\dmvcframework\\lib\\loggerpro;C:\\DEV\\dmvcframework\\lib\\swagdoc\\source;C:\\DEV\\dmvcframework\\contrib;\"C:\\Users\\Daniele Teti\\AppData\\Local\\Programs\\TestInsight\\Source\";C:\\DLib\\smcmpnt\\SOURCES;C:\\DLib\\spring4d\\Library\\Delphi12\\Win32\\Debug;C:\\DEV\\dmvcframework\\contrib;C:\\DLib\\sempare-delphi-template-engine\\src;C:\\DEV\\dmvcframework\\lib\\crosssocket;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Net;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Utils;C:\\DEV\\loggerpro -U\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\lib\\Win32\\debug\";C:\\DLib\\spring4d\\Library\\Delphi12\\Win32\\Debug;..\\..;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\lib\\Win32\\release\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\";\"C:\\Users\\Daniele Teti\\Documents\\Embarcadero\\Studio\\23.0\\Imports\\Win32\";\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\23.0\\include\";C:\\DEV\\dmvcframework\\sources;C:\\DEV\\dmvcframework\\lib\\dmustache;C:\\DEV\\dmvcframework\\lib\\loggerpro;C:\\DEV\\dmvcframework\\lib\\swagdoc\\source;C:\\DEV\\dmvcframework\\contrib;\"C:\\Users\\Daniele Teti\\AppData\\Local\\Programs\\TestInsight\\Source\";C:\\DLib\\smcmpnt\\SOURCES;C:\\DLib\\spring4d\\Library\\Delphi12\\Win32\\Debug;C:\\DEV\\dmvcframework\\contrib;C:\\DLib\\sempare-delphi-template-engine\\src;C:\\DEV\\dmvcframework\\lib\\crosssocket;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Net;C:\\DEV\\dmvcframework\\lib\\crosssocket\\Utils;C:\\DEV\\loggerpro -V -VN -NBC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\Dcp -NHC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\23.0\\hpp\\Win32 -NO.\\Win32\\Debug -LU" , "projectFiles":[ { "name": "FireDACAppenderFormU", "file": "file:///C%3A/DEV/loggerpro/samples/150_DB_appender_firedac/FireDACAppenderFormU.pas" }, { "name": "LoggerProConfig", "file": "file:///C%3A/DEV/loggerpro/samples/150_DB_appender_firedac/LoggerProConfig.pas" }, { "name": "FDConnectionConfigU", "file": "file:///C%3A/DEV/loggerpro/samples/150_DB_appender_firedac/FDConnectionConfigU.pas" } ] , "includeDCUsInUsesCompletion": true, "enableKeyWordCompletion": true, "browsingPaths": [ "file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/OCX/Servers","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/SOURCE/VCL","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/rtl/common","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/SOURCE/RTL/SYS","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/rtl/win","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/rtl/win/winrt","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/ToolsAPI","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/SOURCE/IBX","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/Internet","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/SOURCE/PROPERTY%20EDITORS","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/soap","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/SOURCE/XML","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/Indy10/Core","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/Indy10/System","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/Indy10/Protocols","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/fmx","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/databinding/components","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/databinding/engine","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/databinding/graph","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/ado","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/cloud","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/datasnap","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/dbx","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/dsnap","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/vclctrls","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/datasnap/connectors","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/datasnap/proxygen","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DataExplorer","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/Contrib/DUnitWizard/Source/Common","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/Contrib/DUnitWizard/Source/Common/dunit","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/Contrib/DUnitWizard/Source/DelphiExperts/Common","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/Contrib/DUnitWizard/Source/DelphiExperts/DUnitProject","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/Contrib/DUnitWizard/Source/DelphiExperts/DUnitProject/dunit","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/src","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/tests","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/Experts","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/indy/abstraction","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/indy/implementation","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/indyimpl","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/Property%20Editors/Indy10","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/soap/wsdlimporter","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/Visualizers","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/Contrib/XMLReporting","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnit/Contrib/XPGen","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/rest","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/firedac","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/tethering","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/DUnitX","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/data/ems","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/rtl/net","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/source/FlatBox2D","file:///C%3A/DLib/spring4d/Source","file:///C%3A/DLib/spring4d/Source/Base","file:///C%3A/DLib/spring4d/Source/Base/Collections","file:///C%3A/DLib/spring4d/Source/Base/Logging","file:///C%3A/DLib/spring4d/Source/Base/Patches","file:///C%3A/DLib/spring4d/Source/Core/Container","file:///C%3A/DLib/spring4d/Source/Core/Interception","file:///C%3A/DLib/spring4d/Source/Core/Logging","file:///C%3A/DLib/spring4d/Source/Core/Mocking","file:///C%3A/DLib/spring4d/Source/Core/Services","file:///C%3A/DLib/spring4d/Source/Extensions/Cryptography","file:///C%3A/DLib/spring4d/Source/Extensions/Utils" ] , "CommonAppData": "file:///C%3A/Users/Daniele%20Teti/AppData/Roaming/Embarcadero/BDS/23.0/" , "Templates": "file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/23.0/ObjRepos/" } } \ No newline at end of file diff --git a/samples/150_DB_appender_firedac/FireDACAppenderSample.dpr b/samples/150_DB_appender_firedac/FireDACAppenderSample.dpr new file mode 100644 index 00000000..4e26bebd --- /dev/null +++ b/samples/150_DB_appender_firedac/FireDACAppenderSample.dpr @@ -0,0 +1,19 @@ +program FireDACAppenderSample; + +uses + Vcl.Forms, + FireDACAppenderFormU in 'FireDACAppenderFormU.pas' {MainForm}, + LoggerProConfig in 'LoggerProConfig.pas', + FDConnectionConfigU in 'FDConnectionConfigU.pas'; + +//LoggerPro.RESTAppender in '..\..\LoggerPro.RESTAppender.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + CreatePostgresqlPrivateConnDef(False); + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. diff --git a/samples/150_DB_appender_firedac/FireDACAppenderSample.dproj b/samples/150_DB_appender_firedac/FireDACAppenderSample.dproj new file mode 100644 index 00000000..89a1c4a8 --- /dev/null +++ b/samples/150_DB_appender_firedac/FireDACAppenderSample.dproj @@ -0,0 +1,1104 @@ + + + {6428419F-8F13-4ED8-94A7-2F7860515AAC} + 20.1 + VCL + FireDACAppenderSample.dpr + True + Debug + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + FireDACAppenderSample + $(BDS)\bin\delphi_PROJECTICON.ico + .\$(Platform)\$(Config) + .\$(Platform)\$(Config) + false + false + false + false + false + + + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + ..\..\;$(DCC_UnitSearchPath) + DBXSqliteDriver;DBXDb2Driver;dxCoreRS23;vclactnband;frxe23;vclFireDAC;dxPSLnksRS23;dxPSdxLCLnkRS23;tethering;cxDataRS23;dxPSdxOCLnkRS23;dxTabbedMDIRS23;FireDACADSDriver;dxSkinBlackRS23;dxSkinLondonLiquidSkyRS23;JvPluginSystem;dxDBXServerModeRS23;dxHttpIndyRequestRS23;dxPScxGridLnkRS23;cxSchedulerRS23;FireDACMSSQLDriver;dclRBDBE1723;vcltouch;JvBands;vcldb;rbDB1723;svn;dxWizardControlRS23;dxSkinMcSkinRS23;dxPScxCommonRS23;JvJans;Intraweb;dxSkinOffice2007BlueRS23;rbIBE1723;dxBarRS23;cxSchedulerRibbonStyleEventEditorRS23;dxSkinOffice2013WhiteRS23;JvDotNetCtrls;dxPSTeeChartRS23;cxLibraryRS23;dxSkinVisualStudio2013LightRS23;vclib;cxPivotGridChartRS23;rbDBE1723;dxSkinSummer2008RS23;dxPSdxDBOCLnkRS23;dxGDIPlusRS23;dxSkinDarkSideRS23;FireDACDBXDriver;dxSkinFoggyRS23;dxSkinSevenRS23;vclx;rbCIDE1723;dxSkinOffice2010SilverRS23;dxdborRS23;RESTBackendComponents;dxLayoutControlRS23;dxPSPrVwRibbonRS23;VCLRESTComponents;dxSkinDevExpressStyleRS23;dxSkinWhiteprintRS23;vclie;bindengine;CloudService;rbRAP1723;JvHMI;FireDACMySQLDriver;dxSkinOffice2013DarkGrayRS23;DataSnapClient;dxPScxPCProdRS23;bindcompdbx;DBXSybaseASEDriver;IndyIPServer;dxSkinPumpkinRS23;IndySystem;dsnapcon;cxTreeListdxBarPopupMenuRS23;dclRBIBE1723;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;dxSkinLilianRS23;Jcl;rbADO1723;dxBarDBNavRS23;dxFlowChartRS23;dxSkinOffice2016ColorfulRS23;rbUSER1723;DBXOdbcDriver;FireDACTDataDriver;FMXTee;ipstudiowinclient;soaprtl;DbxCommonDriver;dxSpreadSheetRS23;AsyncProDR;JvManagedThreads;dxSkinOffice2007PinkRS23;dxPSdxSpreadSheetLnkRS23;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;DTKANPRPackage;dxSkinHighContrastRS23;rtl;dxSkinSevenClassicRS23;DbxClientDriver;dxSkinDevExpressDarkStyleRS23;DBXSybaseASADriver;dxNavBarRS23;dxSkinMetropolisDarkRS23;CodeSiteExpressPkg;dxSkinTheAsphaltWorldRS23;JvSystem;SampleListViewMultiDetailAppearancePackage;dxRichEditControlRS23;JvStdCtrls;JvTimeFramework;ipstudiowin;appanalytics;cxPivotGridRS23;rbUSERDesign1723;dxSkinsdxDLPainterRS23;IndyIPClient;dxRibbonRS23;dxPScxVGridLnkRS23;bindcompvcl;frxDB23;vcldbx;dxSkinOffice2007SilverRS23;dxPScxTLLnkRS23;dxMapControlRS23;TeeUI;rbDIDE1723;JvPascalInterpreter;JvDocking;VclSmp;dxPScxSchedulerLnkRS23;cxTreeListRS23;FireDACODBCDriver;JclVcl;DataSnapIndy10ServerTransport;dxRibbonCustomizationFormRS23;dxPSRichEditControlLnkRS23;dxBarExtDBItemsRS23;DataSnapProviderClient;FireDACMongoDBDriver;dxSkiniMaginaryRS23;frx23;dxSpellCheckerRS23;JvControls;dxSkinsdxBarPainterRS23;JvPrintPreview;dxSkinCoffeeRS23;DataSnapServerMidas;RESTComponents;DBXInterBaseDriver;rbRTL1723;dxADOServerModeRS23;emsclientfiredac;DataSnapFireDAC;svnui;dxmdsRS23;dxSkinLiquidSkyRS23;dxdbtrRS23;dxSkinSpringTimeRS23;dxPSDBTeeChartRS23;JvGlobus;HOAsysR;dxSkinscxPCPainterRS23;dxPSCoreRS23;DBXMSSQLDriver;JvMM;dxSkinXmas2008BlueRS23;rbDAD1723;DatasnapConnectorsFreePascal;bindcompfmx;JvNet;DBXOracleDriver;dxSkinSilverRS23;dxSkinValentineRS23;inetdb;JvAppFrm;ipstudiowinwordxp;rbTC1723;FmxTeeUI;dxBarExtItemsRS23;FireDACIBDriver;fmx;fmxdae;DelphiCookbookListViewAppearance;dxServerModeRS23;dxPsPrVwAdvRS23;dxSkinOffice2010BlackRS23;JvWizards;cxPageControlRS23;dxSkinStardustRS23;cxSchedulerGridRS23;dbexpress;IndyCore;dxSkinSharpPlusRS23;UIBD21Win32R;JvPageComps;dsnap;DataSnapCommon;emsclient;FireDACCommon;dxSkinOffice2010BlueRS23;bdertl;JvDB;dxSkinVS2010RS23;dxSkinMetropolisRS23;DataSnapConnectors;cxVerticalGridRS23;soapserver;dxSkinCaramelRS23;frxTee23;dxTileControlRS23;JclDeveloperTools;cxGridRS23;CPortLibDXE;FireDACOracleDriver;DBXMySQLDriver;JvCmp;rbFireDAC1723;DBXFirebirdDriver;FireDACCommonDriver;rbTCUI1723;LockBoxDR;inet;IndyIPCommon;JvCustom;dxSkinDarkRoomRS23;dxDockingRS23;vcl;dxSkinOffice2007GreenRS23;dxPScxExtCommonRS23;JvXPCtrls;dxSkinsCoreRS23;FireDACDb2Driver;dxThemeRS23;dxSkinsdxRibbonPainterRS23;dxSkinVisualStudio2013BlueRS23;rbRest1723;TSG5201;dxSkinMoneyTwinsRS23;dxPSdxFCLnkRS23;dxtrmdRS23;TeeDB;FireDAC;cxSchedulerTreeBrowserRS23;JvCore;dxFireDACServerModeRS23;dxSkinBlueRS23;OverbyteIcsD10SRun;JvCrypt;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;cxEditorsRS23;dxSkinGlassOceansRS23;JvDlgs;JvRuntimeDesign;dxSkinsdxNavBarPainterRS23;dxGaugeControlRS23;ibxpress;Tee;dxSkinSharpRS23;DataSnapServer;ibxbindings;cxPivotGridOLAPRS23;rbIDE1723;vclwinx;FireDACDSDriver;dxSkinBlueprintRS23;dxSkinOffice2007BlackRS23;CustomIPTransport;vcldsnap;rbBDE1723;dxSkinOffice2013LightGrayRS23;bindcomp;DBXInformixDriver;officeXPrt;dxPSdxGaugeControlLnkRS23;dxPScxPivotGridLnkRS23;dxorgcRS23;dxPSdxDBTVLnkRS23;dclRBADO1723;vclribbon;dbxcds;KernowSoftwareFMX;adortl;dclRBFireDAC1723;dclRBE1723;dxComnRS23;dsnapxml;dbrtl;inetdbxpress;IndyProtocols;cxExportRS23;dxSkinOffice2016DarkRS23;JclContainers;dxSkinVisualStudio2013DarkRS23;rbRCL1723;dxSkinscxSchedulerPainterRS23;rbRIDE1723;fmxase;$(DCC_UsePackage) + $(BDS)\bin\default_app.manifest + true + 1033 + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + .\bin + none + + + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + DBXSqliteDriver;DBXDb2Driver;dxCoreRS23;vclactnband;vclFireDAC;dxPSLnksRS23;dxPSdxLCLnkRS23;tethering;cxDataRS23;dxPSdxOCLnkRS23;dxTabbedMDIRS23;FireDACADSDriver;dxSkinBlackRS23;dxSkinLondonLiquidSkyRS23;dxDBXServerModeRS23;dxHttpIndyRequestRS23;dxPScxGridLnkRS23;cxSchedulerRS23;FireDACMSSQLDriver;vcltouch;vcldb;dxWizardControlRS23;dxSkinMcSkinRS23;dxPScxCommonRS23;Intraweb;dxSkinOffice2007BlueRS23;dxBarRS23;cxSchedulerRibbonStyleEventEditorRS23;dxSkinOffice2013WhiteRS23;dxPSTeeChartRS23;cxLibraryRS23;dxSkinVisualStudio2013LightRS23;vclib;cxPivotGridChartRS23;dxSkinSummer2008RS23;dxPSdxDBOCLnkRS23;dxGDIPlusRS23;dxSkinDarkSideRS23;FireDACDBXDriver;dxSkinFoggyRS23;dxSkinSevenRS23;vclx;dxSkinOffice2010SilverRS23;dxdborRS23;RESTBackendComponents;dxLayoutControlRS23;dxPSPrVwRibbonRS23;VCLRESTComponents;dxSkinDevExpressStyleRS23;dxSkinWhiteprintRS23;vclie;bindengine;CloudService;FireDACMySQLDriver;dxSkinOffice2013DarkGrayRS23;DataSnapClient;dxPScxPCProdRS23;bindcompdbx;DBXSybaseASEDriver;IndyIPServer;dxSkinPumpkinRS23;IndySystem;dsnapcon;cxTreeListdxBarPopupMenuRS23;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;dxSkinLilianRS23;dxBarDBNavRS23;dxFlowChartRS23;dxSkinOffice2016ColorfulRS23;DBXOdbcDriver;FireDACTDataDriver;FMXTee;ipstudiowinclient;soaprtl;DbxCommonDriver;dxSpreadSheetRS23;AsyncProDR;dxSkinOffice2007PinkRS23;dxPSdxSpreadSheetLnkRS23;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;dxSkinHighContrastRS23;rtl;dxSkinSevenClassicRS23;DbxClientDriver;dxSkinDevExpressDarkStyleRS23;DBXSybaseASADriver;dxNavBarRS23;dxSkinMetropolisDarkRS23;dxSkinTheAsphaltWorldRS23;dxRichEditControlRS23;ipstudiowin;appanalytics;cxPivotGridRS23;dxSkinsdxDLPainterRS23;IndyIPClient;dxRibbonRS23;dxPScxVGridLnkRS23;bindcompvcl;dxSkinOffice2007SilverRS23;dxPScxTLLnkRS23;dxMapControlRS23;TeeUI;VclSmp;dxPScxSchedulerLnkRS23;cxTreeListRS23;FireDACODBCDriver;DataSnapIndy10ServerTransport;dxRibbonCustomizationFormRS23;dxPSRichEditControlLnkRS23;dxBarExtDBItemsRS23;DataSnapProviderClient;FireDACMongoDBDriver;dxSkiniMaginaryRS23;dxSpellCheckerRS23;dxSkinsdxBarPainterRS23;dxSkinCoffeeRS23;DataSnapServerMidas;RESTComponents;DBXInterBaseDriver;dxADOServerModeRS23;emsclientfiredac;DataSnapFireDAC;dxmdsRS23;dxSkinLiquidSkyRS23;dxdbtrRS23;dxSkinSpringTimeRS23;dxPSDBTeeChartRS23;dxSkinscxPCPainterRS23;dxPSCoreRS23;DBXMSSQLDriver;dxSkinXmas2008BlueRS23;DatasnapConnectorsFreePascal;bindcompfmx;DBXOracleDriver;dxSkinSilverRS23;dxSkinValentineRS23;inetdb;FmxTeeUI;dxBarExtItemsRS23;FireDACIBDriver;fmx;fmxdae;dxServerModeRS23;dxPsPrVwAdvRS23;dxSkinOffice2010BlackRS23;cxPageControlRS23;dxSkinStardustRS23;cxSchedulerGridRS23;dbexpress;IndyCore;dxSkinSharpPlusRS23;dsnap;DataSnapCommon;emsclient;FireDACCommon;dxSkinOffice2010BlueRS23;dxSkinVS2010RS23;dxSkinMetropolisRS23;DataSnapConnectors;cxVerticalGridRS23;soapserver;dxSkinCaramelRS23;dxTileControlRS23;cxGridRS23;FireDACOracleDriver;DBXMySQLDriver;DBXFirebirdDriver;FireDACCommonDriver;LockBoxDR;inet;IndyIPCommon;dxSkinDarkRoomRS23;dxDockingRS23;vcl;dxSkinOffice2007GreenRS23;dxPScxExtCommonRS23;dxSkinsCoreRS23;FireDACDb2Driver;dxThemeRS23;dxSkinsdxRibbonPainterRS23;dxSkinVisualStudio2013BlueRS23;dxSkinMoneyTwinsRS23;dxPSdxFCLnkRS23;dxtrmdRS23;TeeDB;FireDAC;cxSchedulerTreeBrowserRS23;dxFireDACServerModeRS23;dxSkinBlueRS23;OverbyteIcsD10SRun;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;cxEditorsRS23;dxSkinGlassOceansRS23;dxSkinsdxNavBarPainterRS23;dxGaugeControlRS23;ibxpress;Tee;dxSkinSharpRS23;DataSnapServer;ibxbindings;cxPivotGridOLAPRS23;vclwinx;FireDACDSDriver;dxSkinBlueprintRS23;dxSkinOffice2007BlackRS23;CustomIPTransport;vcldsnap;dxSkinOffice2013LightGrayRS23;bindcomp;DBXInformixDriver;officeXPrt;dxPSdxGaugeControlLnkRS23;dxPScxPivotGridLnkRS23;dxorgcRS23;dxPSdxDBTVLnkRS23;vclribbon;dbxcds;adortl;dxComnRS23;dsnapxml;dbrtl;inetdbxpress;IndyProtocols;cxExportRS23;dxSkinOffice2016DarkRS23;dxSkinVisualStudio2013DarkRS23;dxSkinscxSchedulerPainterRS23;fmxase;$(DCC_UsePackage) + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + Debug + 1033 + true + false + PerMonitor + CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + PerMonitor + + + + MainSource + + +
MainForm
+
+ + + + Base + + + Cfg_1 + Base + + + Cfg_2 + Base + +
+ + Delphi.Personality.12 + Application + + + + FireDACAppenderSample.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + FireDACAppenderSample.exe + true + + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + classes + 64 + + + classes + 64 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v21 + 1 + + + res\drawable-anydpi-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values-v31 + 1 + + + res\values-v31 + 1 + + + + + res\drawable-anydpi-v26 + 1 + + + res\drawable-anydpi-v26 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v33 + 1 + + + res\drawable-anydpi-v33 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-night-v21 + 1 + + + res\values-night-v21 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable-anydpi-v24 + 1 + + + res\drawable-anydpi-v24 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-night-anydpi-v21 + 1 + + + res\drawable-night-anydpi-v21 + 1 + + + + + res\drawable-anydpi-v31 + 1 + + + res\drawable-anydpi-v31 + 1 + + + + + res\drawable-night-anydpi-v31 + 1 + + + res\drawable-night-anydpi-v31 + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + ..\ + 1 + + + + + Contents + 1 + + + Contents + 1 + + + Contents + 1 + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen + 64 + + + ..\$(PROJECTNAME).launchscreen + 64 + + + + + 1 + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + + + + + + + + + + + + + True + False + + + 12 + + + + +
diff --git a/samples/150_DB_appender_firedac/LoggerProConfig.pas b/samples/150_DB_appender_firedac/LoggerProConfig.pas new file mode 100644 index 00000000..84ba8d7b --- /dev/null +++ b/samples/150_DB_appender_firedac/LoggerProConfig.pas @@ -0,0 +1,112 @@ +unit LoggerProConfig; + +// instantiate and call the Logging appender that writes to the Logging database + +interface + +uses + LoggerPro; + +///global function pointer tha returns a DB Logger instance +var + Log: function: ILogWriter; + +implementation + +uses + System.SysUtils, + System.Classes, + LoggerPro.DBAppender.FireDAC, + LoggerPro.FileAppender, + Data.DB, + System.IOUtils, + System.NetEncoding, + FireDAC.Stan.Intf, + FireDAC.Stan.Option, + FireDAC.Stan.Error, + FireDAC.UI.Intf, + FireDAC.Phys.Intf, + FireDAC.Stan.Def, + FireDAC.Stan.Pool, + FireDAC.Stan.Async, + FireDAC.Stan.Param, + FireDAC.Phys, + FireDAC.VCLUI.Wait, + FireDAC.Comp.Client, + FDConnectionConfigU, + LoggerPro.Renderers; + +var + _Log: ILogWriter; + _FallbackLog: ILogWriter; + +const + FailedDBWriteTag = 'FailedDBWrite'; + + +function GetFallBackLogger: ILogWriter; +begin + if _FallbackLog = nil then + begin + _FallbackLog := BuildLogWriter([ + TLoggerProSimpleFileAppender.Create(10, 2048, 'logs') + ]); + end; + Result := _FallbackLog; +end; + +function GetLogger: ILogWriter; +begin + + if _Log = nil then + begin + GetFallBackLogger.Info('Initializing db appender', FailedDBWriteTag); + + _Log := BuildLogWriter([TLoggerProDBAppenderFireDAC.Create( + // create an ADO DB Connection + function: TCustomConnection + begin + Result := TFDConnection.Create(nil); + Result.LoginPrompt := False; + // todo: set the connection string in here, typically read from env variables or config file + TFDConnection(Result).ConnectionDefName := CON_DEF_NAME; + end, + // create a stored proc + function(Connection: TCustomConnection): TFDStoredProc + begin + Result := TFDStoredProc.Create(nil); + Result.StoredProcName := 'sp_loggerpro_writer'; + Result.Connection := Connection as TFDConnection; + end, + // populate the stored proc + procedure(SP: TFDStoredProc; LogItem: TLogItem) + begin + SP.ParamByName('p_log_type').Value := Integer(LogItem.LogType); + SP.ParamByName('p_log_tag').Value := LogItem.LogTag; + SP.ParamByName('p_log_message').Value := LogItem.LogMessage; + SP.ParamByName('p_log_timestamp').Value := LogItem.TimeStamp; + SP.ParamByName('p_log_thread_id').Value := LogItem.ThreadID; + end, + // error handler, just write to disk on the server for later analysis + procedure(const Sender: TObject; const LogItem: TLogItem; const DBError: Exception; var RetryCount: Integer) + var + lIntf: ILogItemRenderer; + begin + lIntf := GetDefaultLogItemRenderer(); + GetFallBackLogger.Error('DBAppender Is Failing (%d): %s %s', [RetryCount, DBError.ClassName, DBError.Message], FailedDBWriteTag); + GetFallBackLogger.Error(lIntf.RenderLogItem(LogItem), FailedDBWriteTag); + end)]); + end; + Result := _Log; +end; + +initialization + +Log := GetLogger; + +finalization + +_Log := nil; +_FallbackLog := nil; + +end. diff --git a/samples/150_DB_appender_firedac/postgresql_ddl.sql b/samples/150_DB_appender_firedac/postgresql_ddl.sql new file mode 100644 index 00000000..dca5e41c --- /dev/null +++ b/samples/150_DB_appender_firedac/postgresql_ddl.sql @@ -0,0 +1,27 @@ +drop procedure if exists sp_loggerpro_writer; +drop table if exists loggerpro_logs; + +create table loggerpro_logs ( + id int generated by default as identity, + log_type int, + log_tag varchar, + log_message varchar, + log_timestamp timestamp, + log_thread_id integer +); + +create or replace procedure sp_loggerpro_writer( + p_log_type int, + p_log_tag varchar, + p_log_message varchar, + p_log_timestamp timestamp, + p_log_thread_id integer +) +language plpgsql +as $$ +begin + INSERT INTO + public.loggerpro_logs(log_type, log_tag, log_message, log_timestamp, log_thread_id) + values (p_log_type, p_log_tag, p_log_message, p_log_timestamp, p_log_thread_id); +end; +$$; \ No newline at end of file diff --git a/samples/50_custom_appender/LoggerProConfig.pas b/samples/50_custom_appender/LoggerProConfig.pas index ead7412c..c686df01 100644 --- a/samples/50_custom_appender/LoggerProConfig.pas +++ b/samples/50_custom_appender/LoggerProConfig.pas @@ -41,11 +41,10 @@ end; procedure TMyCustomAppender.WriteLog(const aLogItem: TLogItem); begin - // uncomment this to see what happend if an appender raise an exception - + // uncomment this to see what happens if an appender raise an exception // raise Exception.Create('Kill LoggerPro'); - // uncomment this to see what happend if an appender is slow + // uncomment this to see what happens if an appender is slow Sleep(2000); WriteLn('[THE BAD APPENDER] ' + aLogItem.LogMessage); end;