aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/ULog.pas
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/Code/Classes/ULog.pas
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 '')
-rw-r--r--Game/Code/Classes/ULog.pas38
1 files changed, 23 insertions, 15 deletions
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);