aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-02 16:43:05 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-02 16:43:05 +0000
commitfffe085266382cfcaeed4b600f4d6bb104bfa38d (patch)
tree9a55c9eea579af04dc3fabc4e970973388ee4954 /Game
parent97b5f227669651bc71328296e95df386a31ddf7b (diff)
downloadusdx-fffe085266382cfcaeed4b600f4d6bb104bfa38d.tar.gz
usdx-fffe085266382cfcaeed4b600f4d6bb104bfa38d.tar.xz
usdx-fffe085266382cfcaeed4b600f4d6bb104bfa38d.zip
- replaced some DebugWriteln() with Log.Log...()
- added LogFileLevel to be able to control which log-messages are written to the log-file (Error.log) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1053 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Classes/UDataBase.pas9
-rw-r--r--Game/Code/Classes/ULog.pas38
-rw-r--r--Game/Code/Classes/USongs.pas2
-rw-r--r--Game/Code/Classes/UThemes.pas8
4 files changed, 32 insertions, 25 deletions
diff --git a/Game/Code/Classes/UDataBase.pas b/Game/Code/Classes/UDataBase.pas
index 7469e8af..3954f92e 100644
--- a/Game/Code/Classes/UDataBase.pas
+++ b/Game/Code/Classes/UDataBase.pas
@@ -65,6 +65,7 @@ implementation
uses
IniFiles,
ULog,
+ StrUtils,
SysUtils;
const
@@ -77,7 +78,7 @@ const
Procedure TDataBaseSystem.Init(const Filename: string);
begin
- debugWriteln( 'TDataBaseSystem.Init ('+Filename+') @ '+ floattostr( now() ) );
+ Log.LogStatus('Initializing database: "'+Filename+'"', 'TDataBaseSystem.Init');
//Open Database
ScoreDB := TSqliteDatabase.Create( Filename );
@@ -103,8 +104,10 @@ begin
finally
- debugWriteln( cUS_Songs +' Exist : ' + inttostr( integer(ScoreDB.TableExists( cUS_Songs )) ) );
- debugWriteln( cUS_Scores +' Exist : ' + inttostr( integer(ScoreDB.TableExists( cUS_Scores )) ) );
+ Log.LogInfo( cUS_Songs +' exists: ' + IfThen(ScoreDB.TableExists(cUS_Songs), 'true', 'false'),
+ 'TDataBaseSystem.Init');
+ Log.LogInfo( cUS_Scores +' exists: ' + IfThen(ScoreDB.TableExists(cUS_Scores), 'true', 'false'),
+ 'TDataBaseSystem.Init');
//ScoreDB.Free;
end;
diff --git a/Game/Code/Classes/ULog.pas b/Game/Code/Classes/ULog.pas
index d2664b1e..ca488e7e 100644
--- a/Game/Code/Classes/ULog.pas
+++ b/Game/Code/Classes/ULog.pas
@@ -35,8 +35,10 @@ const
LOG_LEVEL_CRITICAL_MAX = LOG_LEVEL_ERROR-1;
LOG_LEVEL_CRITICAL = 0;
LOG_LEVEL_NONE = -1;
-
- LOG_LEVEL_DEFAULT = LOG_LEVEL_ERROR;
+
+ // define level that Log(File)Level is initialized with
+ LOG_LEVEL_DEFAULT = LOG_LEVEL_INFO;
+ LOG_FILE_LEVEL_DEFAULT = LOG_LEVEL_ERROR;
type
TLog = class
@@ -47,6 +49,8 @@ type
BenchmarkFileOpened: boolean;
LogLevel: integer;
+ // level of messages written to the log-file
+ LogFileLevel: integer;
procedure LogToFile(const Text: string);
public
@@ -125,6 +129,7 @@ end;
constructor TLog.Create;
begin
LogLevel := LOG_LEVEL_DEFAULT;
+ LogFileLevel := LOG_FILE_LEVEL_DEFAULT;
FileOutputEnabled := true;
end;
@@ -279,6 +284,8 @@ 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
begin
if (Level <= LOG_LEVEL_CRITICAL_MAX) then
@@ -295,24 +302,25 @@ begin
LogMsg := 'DEBUG: ' + Text;
// output log-message
- DebugWriteLn(LogMsg);
-
- // actions for error- and more severe levels
- if (Level <= LOG_LEVEL_ERROR_MAX) then
+ if (Level <= LogLevel) then
begin
- // Write message to log-file
- LogToFile(Text);
+ DebugWriteLn(LogMsg);
end;
-
- // actions for critical- and more severe levels
- if (Level <= LOG_LEVEL_CRITICAL_MAX) then
+
+ // write message to log-file
+ if (Level <= LogFileLevel) then
begin
- // Show information (window)
- ShowMessage(Text, mtError);
- // Exit Application
- Halt;
+ LogToFile(LogMsg);
end;
end;
+
+ // exit application on criticial errors (cannot be turned off)
+ if (Level <= LOG_LEVEL_CRITICAL_MAX) then
+ begin
+ // Show information (window)
+ ShowMessage(Text, mtError);
+ Halt;
+ end;
end;
procedure TLog.LogMsg(const Msg, Context: string; Level: integer);
diff --git a/Game/Code/Classes/USongs.pas b/Game/Code/Classes/USongs.pas
index fd9accb5..ebc42efe 100644
--- a/Game/Code/Classes/USongs.pas
+++ b/Game/Code/Classes/USongs.pas
@@ -185,7 +185,7 @@ begin
if fParseSongDirectory then
begin
- debugWriteln( 'int_LoadSongList' );
+ Log.LogStatus('Calling int_LoadSongList', 'TSongs.Execute');
int_LoadSongList();
end;
diff --git a/Game/Code/Classes/UThemes.pas b/Game/Code/Classes/UThemes.pas
index 36ad99b0..dc9e2935 100644
--- a/Game/Code/Classes/UThemes.pas
+++ b/Game/Code/Classes/UThemes.pas
@@ -811,17 +811,13 @@ begin
create_theme_objects();
- debugWriteln( 'TTheme.LoadTheme : '+ FileName );
+ Log.LogStatus('Loading: '+ FileName, 'TTheme.LoadTheme');
FileName := AdaptFilePaths( FileName );
if not FileExists(FileName) then
begin
- {$ifndef win32}
- debugWriteln( 'ERROR !!! Theme does not exist ('+ FileName +')' );
- {$endif}
-
- Log.LogStatus( 'ERROR !!! Theme does not exist ('+ FileName +')' , 'TTheme.LoadTheme');
+ Log.LogError('Theme does not exist ('+ FileName +')', 'TTheme.LoadTheme');
end;
if FileExists(FileName) then