2014-05-20 06:59:10 +00:00
|
|
|
unit X2Log.Global;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
|
2014-05-28 11:49:48 +00:00
|
|
|
X2Log,
|
2014-05-20 06:59:10 +00:00
|
|
|
X2Log.Intf;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TX2GlobalLog = class(TObject)
|
2014-05-31 20:10:10 +00:00
|
|
|
private
|
|
|
|
class var FInstance: IX2Log;
|
2014-05-20 08:49:57 +00:00
|
|
|
protected
|
|
|
|
class procedure CleanupInstance;
|
2014-05-20 06:59:10 +00:00
|
|
|
public
|
|
|
|
class function Instance: IX2Log;
|
|
|
|
|
|
|
|
{ Facade for IX2Log }
|
|
|
|
class procedure Attach(AObserver: IX2LogObserver);
|
|
|
|
class procedure Detach(AObserver: IX2LogObserver);
|
|
|
|
|
|
|
|
class procedure SetExceptionStrategy(AStrategy: IX2LogExceptionStrategy);
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
{ Facade for IX2LogBase }
|
2014-10-20 12:07:44 +00:00
|
|
|
class procedure Log(ALevel: TX2LogLevel; const AMessage: string; const ACategory: string = ''; ADetails: IX2LogDetails = nil); overload;
|
|
|
|
class procedure Log(ALevel: TX2LogLevel; ADateTime: TDateTime; const AMessage: string; const ACategory: string = ''; ADetails: IX2LogDetails = nil); overload;
|
|
|
|
|
|
|
|
class function Category(const ACategory: string): IX2Log;
|
2014-05-20 06:59:10 +00:00
|
|
|
|
|
|
|
class procedure Verbose(const AMessage: string; const ADetails: string = '');
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure VerboseEx(const AMessage: string; ADetails: IX2LogDetails = nil);
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure Info(const AMessage: string; const ADetails: string = '');
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure InfoEx(const AMessage: string; ADetails: IX2LogDetails = nil);
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure Warning(const AMessage: string; const ADetails: string = '');
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure WarningEx(const AMessage: string; ADetails: IX2LogDetails = nil);
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure Error(const AMessage: string; const ADetails: string = '');
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure ErrorEx(const AMessage: string; ADetails: IX2LogDetails = nil);
|
|
|
|
|
|
|
|
class procedure Exception(AException: Exception; const AMessage: string = '');
|
2014-05-20 06:59:10 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
2014-05-30 12:51:01 +00:00
|
|
|
uses
|
|
|
|
X2Log.Details.Default;
|
2014-05-20 06:59:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
{ TX2GlobalLog }
|
|
|
|
class function TX2GlobalLog.Instance: IX2Log;
|
|
|
|
begin
|
|
|
|
if not Assigned(FInstance) then
|
|
|
|
FInstance := TX2Log.Create;
|
|
|
|
|
|
|
|
Result := FInstance;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-20 08:49:57 +00:00
|
|
|
class procedure TX2GlobalLog.CleanupInstance;
|
|
|
|
begin
|
2014-05-30 13:06:47 +00:00
|
|
|
FInstance := nil;
|
2014-05-20 08:49:57 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure TX2GlobalLog.Attach(AObserver: IX2LogObserver);
|
|
|
|
begin
|
|
|
|
Instance.Attach(AObserver);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Detach(AObserver: IX2LogObserver);
|
|
|
|
begin
|
|
|
|
instance.Detach(AObserver);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.SetExceptionStrategy(AStrategy: IX2LogExceptionStrategy);
|
|
|
|
begin
|
|
|
|
Instance.SetExceptionStrategy(AStrategy);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-10-20 12:07:44 +00:00
|
|
|
class function TX2GlobalLog.Category(const ACategory: string): IX2Log;
|
|
|
|
begin
|
|
|
|
Result := Instance.Category(ACategory);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Log(ALevel: TX2LogLevel; const AMessage, ACategory: string; ADetails: IX2LogDetails);
|
2014-05-20 06:59:10 +00:00
|
|
|
begin
|
2014-10-20 12:07:44 +00:00
|
|
|
Instance.Log(ALevel, AMessage, ACategory, ADetails);
|
2014-05-20 06:59:10 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-10-20 12:07:44 +00:00
|
|
|
class procedure TX2GlobalLog.Log(ALevel: TX2LogLevel; ADateTime: TDateTime; const AMessage, ACategory: string; ADetails: IX2LogDetails);
|
2014-10-08 12:33:11 +00:00
|
|
|
begin
|
2014-10-20 12:07:44 +00:00
|
|
|
Instance.Log(ALevel, ADateTime, AMessage, ACategory, ADetails);
|
2014-10-08 12:33:11 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure TX2GlobalLog.Verbose(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Verbose(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure TX2GlobalLog.VerboseEx(const AMessage: string; ADetails: IX2LogDetails);
|
|
|
|
begin
|
|
|
|
Instance.VerboseEx(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure TX2GlobalLog.Info(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Info(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure TX2GlobalLog.InfoEx(const AMessage: string; ADetails: IX2LogDetails);
|
|
|
|
begin
|
|
|
|
Instance.InfoEx(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure TX2GlobalLog.Warning(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Warning(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure TX2GlobalLog.WarningEx(const AMessage: string; ADetails: IX2LogDetails);
|
|
|
|
begin
|
|
|
|
Instance.WarningEx(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
class procedure TX2GlobalLog.Error(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Error(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
class procedure TX2GlobalLog.ErrorEx(const AMessage: string; ADetails: IX2LogDetails);
|
|
|
|
begin
|
|
|
|
Instance.ErrorEx(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Exception(AException: Exception; const AMessage: string);
|
2014-05-20 06:59:10 +00:00
|
|
|
begin
|
2014-05-30 12:51:01 +00:00
|
|
|
Instance.Exception(AException, AMessage);
|
2014-05-20 06:59:10 +00:00
|
|
|
end;
|
|
|
|
|
2014-05-20 08:49:57 +00:00
|
|
|
|
|
|
|
initialization
|
|
|
|
finalization
|
|
|
|
TX2GlobalLog.CleanupInstance;
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
end.
|