unit BaseLogger; interface uses mybean.core.objects, Classes, SysUtils, StrUtils, WindowsSysVersion, superobject, Dialogs, IdHTTP, ULogger, InterfaceLogger, DateUtils; type TBaseLogger = class(TMyBeanInterfacedObject, ILogger) private FLoginName: string; FIP: string; FPlatform: string; FEnable: Boolean; FUrl, FAppCode, FClientVersion: string; public procedure Log(AMessage, ACode, ALoginName: string); overload; virtual; stdcall; procedure Log(AMessage, ACode, ALoginName, AStrLevel: string); overload; virtual; stdcall; procedure AsynLog(AMessage, ACode, ALoginName: string); virtual; stdcall; procedure Success(AMessage, ACode, ALoginName: string); virtual; stdcall; procedure Info(AMessage, ACode, ALoginName: string); virtual; stdcall; procedure Debug(AMessage, ACode, ALoginName: string); virtual; stdcall; procedure Warning(AMessage, ACode, ALoginName: string); virtual; stdcall; procedure Error(AMessage, ACode, ALoginName: string); virtual; stdcall; procedure Init; procedure LoadConfig; constructor Create; override; end; implementation { TBaseLogger } procedure TBaseLogger.AsynLog(AMessage, ACode, ALoginName: string); begin end; constructor TBaseLogger.Create; begin inherited; LoadConfig; Init; end; procedure TBaseLogger.Debug(AMessage, ACode, ALoginName: string); begin Log(AMessage, ACode, ALoginName, 'debug'); end; procedure TBaseLogger.Error(AMessage, ACode, ALoginName: string); begin Log(AMessage, ACode, ALoginName, 'error'); end; procedure TBaseLogger.Info(AMessage, ACode, ALoginName: string); begin Log(AMessage, ACode, ALoginName, 'info'); end; procedure TBaseLogger.Init; begin try FPlatform := ''; FIP := '0.0.0.0'; case GetWindowsSystemVersion of WinNone: FPlatform := ''; Win95: FPlatform := 'Windows 95'; Win98: FPlatform := 'Windows 98'; WinMe: FPlatform := 'Windows Me'; Win2000: FPlatform := 'Windows 2000'; WinServer2000: FPlatform := 'Windows Server 2000'; WinXp: FPlatform := 'Windows XP'; WinXp64: FPlatform := 'Windows XP x64'; WinServer2003: FPlatform := 'Windows Server 2003'; WinHomeServer: FPlatform := 'Windows Home Server'; WinServer2003R2: FPlatform := 'Windows Server 2003 R2'; WinVista: FPlatform := 'Windows Vista'; WinServer2008: FPlatform := 'Windows Server 2008'; WinServer2008R2: FPlatform := 'Windows Server 2008 R2'; Win7: FPlatform := 'Windows 7'; end; FIP := LocalIP; except on E: Exception do begin Dialogs.ShowMessage(E.Message); end; end; end; procedure TBaseLogger.LoadConfig; var AFullPath: string; jo: ISuperObject; begin AFullPath := ExtractFilePath(ParamStr(0)) + CONFIG_DIR; if not FileExists(AFullPath) then begin FEnable := False; Exit; end; try jo := TSuperObject.ParseFile(AFullPath, False); FEnable := jo['enable'].AsBoolean(); FUrl := jo['url'].AsString(); FAppCode := jo['appCode'].AsString(); FClientVersion := jo['clientVersion'].AsString(); except on E: Exception do begin FEnable := False; Dialogs.ShowMessage(E.Message); end; end; end; procedure TBaseLogger.Log(AMessage, ACode, ALoginName, AStrLevel: string); begin end; procedure TBaseLogger.Log(AMessage, ACode, ALoginName: string); begin Log(AMessage, ACode, ALoginName, 'error'); end; procedure TBaseLogger.Success(AMessage, ACode, ALoginName: string); begin Log(AMessage, ACode, ALoginName, 'success'); end; procedure TBaseLogger.Warning(AMessage, ACode, ALoginName: string); begin Log(AMessage, ACode, ALoginName, 'warning'); end; end.