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-20 08:49:57 +00:00
|
|
|
private class var
|
2014-05-28 11:49:48 +00:00
|
|
|
FInstance: TX2Log;
|
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-05-20 06:59:10 +00:00
|
|
|
class procedure Log(ALevel: TX2LogLevel; const AMessage: string; const ADetails: string = '');
|
|
|
|
|
|
|
|
class procedure Verbose(const AMessage: string; const ADetails: string = '');
|
|
|
|
class procedure Info(const AMessage: string; const ADetails: string = '');
|
|
|
|
class procedure Warning(const AMessage: string; const ADetails: string = '');
|
|
|
|
class procedure Error(const AMessage: string; const ADetails: string = '');
|
|
|
|
class procedure Exception(AException: Exception; const AMessage: string = ''; const ADetails: string = '');
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{ 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
|
|
|
|
if Assigned(FInstance) then
|
|
|
|
FreeAndNil(FInstance);
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Log(ALevel: TX2LogLevel; const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Log(ALevel, AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Verbose(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Verbose(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Info(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Info(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Warning(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Warning(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Error(const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Error(AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class procedure TX2GlobalLog.Exception(AException: Exception; const AMessage, ADetails: string);
|
|
|
|
begin
|
|
|
|
Instance.Exception(AException, AMessage, ADetails);
|
|
|
|
end;
|
|
|
|
|
2014-05-20 08:49:57 +00:00
|
|
|
|
|
|
|
initialization
|
|
|
|
finalization
|
|
|
|
TX2GlobalLog.CleanupInstance;
|
|
|
|
|
2014-05-20 06:59:10 +00:00
|
|
|
end.
|