From ef87526bdda394dff43fa3600a4c6936508e3791 Mon Sep 17 00:00:00 2001 From: basisbit Date: Sat, 15 Aug 2015 01:23:56 +0000 Subject: *added try catch on UMain.Main for better overall error handling *added SetLogFileLevel and GetLogFileLevel for easier debugging (logging more to file) *if (LogFileLevel < LogLevel) then still do logging if important error message git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3117 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UConfig.pas | 10 ++++++++++ src/base/ULog.pas | 16 +++++++++++++--- src/ultrastardx.dpr | 12 +++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/base/UConfig.pas b/src/base/UConfig.pas index e48b5493..23ef0f3f 100644 --- a/src/base/UConfig.pas +++ b/src/base/UConfig.pas @@ -203,6 +203,16 @@ const (LIBSAMPLERATE_VERSION_RELEASE * VERSION_RELEASE); {$ENDIF} + {$IFNDEF lua_VERSION_MAJOR} + LUA_VERSION_MAJOR = '5'; + {$ENDIF} + {$IFNDEF lua_VERSION_MINOR} + LUA_VERSION_MINOR = '1'; + {$ENDIF} + {$IFNDEF lua_VERSION_RELEASE} + LUA_VERSION_RELEASE = '4'; + {$ENDIF} + function USDXVersionStr(): string; function USDXShortVersionStr(): string; diff --git a/src/base/ULog.pas b/src/base/ULog.pas index ea3cda4e..bde4d4e4 100644 --- a/src/base/ULog.pas +++ b/src/base/ULog.pas @@ -100,6 +100,8 @@ type procedure SetLogLevel(Level: integer); function GetLogLevel(): integer; + procedure SetLogFileLevel(Level: integer); + function GetLogFileLevel(): integer; procedure LogMsg(const Text: string; Level: integer); overload; procedure LogMsg(const Msg, Context: string; Level: integer); overload; {$IFDEF HasInline}inline;{$ENDIF} @@ -311,13 +313,21 @@ begin Result := LogLevel; end; +procedure TLog.SetLogFileLevel(Level: integer); +begin + LogFileLevel := Level; +end; + +function TLog.GetLogFileLevel(): integer; +begin + Result := LogFileLevel; +end; + procedure TLog.LogMsg(const Text: string; Level: integer); var LogMsg: string; begin - // TODO: what if (LogFileLevel < LogLevel)? Log to file without printing to - // console or do not log at all? At the moment nothing is logged. - if (Level <= LogLevel) then + if ((Level <= LogLevel) or (Level <= LogFileLevel)) then begin if (Level <= LOG_LEVEL_CRITICAL_MAX) then LogMsg := 'CRITICAL: ' + Text diff --git a/src/ultrastardx.dpr b/src/ultrastardx.dpr index 0523f818..2280d4c6 100644 --- a/src/ultrastardx.dpr +++ b/src/ultrastardx.dpr @@ -350,7 +350,17 @@ uses SysUtils; +const + sLineBreak = {$IFDEF LINUX} AnsiChar(#10) {$ENDIF} + {$IFDEF MSWINDOWS} AnsiString(#13#10) {$ENDIF}; begin - Main; + try + Main; + except + on E : Exception do + begin + ShowMessage('Exception class name = '+E.ClassName+sLineBreak+'Exception message = '+E.Message); + end; + end; end. -- cgit v1.2.3