| Logging.pas Updated 20 Sep 2008 | Upper levels: - QuArK Information Base - 4. The Source Code - 4.5. File-by-file descriptions

4.5.4. Logging.pas | [ Prev - Up - Next ]

This file contains all functions that deal with the QuArK.LOG file.

Index

- - Constants (20 Sep 2008)
- - Types (20 Sep 2008)
- - OpenLogFile (20 Sep 2008)
- - CloseLogFile (20 Sep 2008)
- - Log (20 Sep 2008)
- - aLog (20 Sep 2008)
- - GetPatchVersion (20 Sep 2008)

Constants | DanielPharos - 20 Sep 2008 | [ Top ]

      LOG_FILENAME = 'QUARK.LOG';
      LOG_PATCHFILE = 'PATCH.TXT';

      LOG_ALWAYS = 0;
      LOG_CRITICAL = 10;
      LOG_WARNING = 20;
      LOG_INFO = 30;
      LOG_VERBOSE = 40;
All these constants are used by the logging procedures or their callers. `LOG_FILENAME` is the filename of the logfile. The path of the logfile is set in `OpenLogFile` . `LOG_PATCHFILE` is not used anymore. `LOG_*` are a bunch of constants that define the default verbose output levels. Their names describe when the log-line what kind of info it contains. See `Log` for more info about what this means.

Types | DanielPharos - 20 Sep 2008 | [ Top ]

      TLogName = (LOG_DEFAULT, LOG_PASCAL, LOG_PYTHON, LOG_SYS, LOG_DEBUG);
This type is used by the callers of the `Log` procedure. `TLogName` is the name of the logger/'outputer' that will appear in front of the log-line. The following table describes all the options:

LOG_DEFAULT | Outputs 'Log' This is the default. Use this when no other options apply.

LOG_PASCAL | Outputs 'QuArKLog' You can use this when an error in the Pascal/Delphi code has occured.

LOG_PYTHON | Outputs 'PythonLog' You can use this when an error in the Python code has occured.

LOG_SYS | Outputs 'SysLog' This is used in the SystemDetails.pas. Use this only in this module.

LOG_DEBUG | Outputs 'DebugLog' Use this for debug-output to the log. You should only use these in debug code, so they do not appear in the logfile in release-files.

OpenLogFile | DanielPharos - 20 Sep 2008 | [ Top ]

    Procedure OpenLogFile;
This procedure opens and clears the logfile. It first checks if there already is a log open (using the boolean `LogOpened` ). If not, it then either creates a new file, or opens an existing file and blanks it. The filename is `GetQPath(pQuArK)+LogFilename` . It then invokes the procedure that outputs the system details into the logfile.

CloseLogFile | DanielPharos - 20 Sep 2008 | [ Top ]

    Procedure CloseLogFile;
This procedure closes the logfile. It first checks if the log is open (using the boolean `LogOpened` ). If it is, it writes the date and time to the log, and closes it.

Log | DanielPharos - 20 Sep 2008 | [ Top ]

    Procedure Log(s: string); overload;
    Procedure Log(level: cardinal; s: string); overload;
    Procedure Log(s: string; args: array of const); overload;
    Procedure Log(level: cardinal; s: string; args: array of const); overload;
    Procedure Log(Logger: TLogName; s: string); overload;
    Procedure Log(Logger: TLogName; level: cardinal; s: string); overload;
    Procedure Log(Logger: TLogName; s: string; args: array of const); overload;
    Procedure Log(Logger: TLogName; level: cardinal; s: string; args: array of const); overload;
These procedures all do the same thing: they write something to the log. There are all defined with `overload` , so the parameters define which procedure is picked. So let's only describe the two longest ones, since the rest is just smaller versions.
    Procedure Log(Logger: TLogName; level: cardinal; s: string); overload;
    Procedure Log(Logger: TLogName; level: cardinal; s: string; args: array of const); overload;
`Logger` is the TLogName that should appear in front of the log-line. `level` is the priority-level of the ouput. This is compared to `LogLevel` variable, and a log-line is only written if the `level` is smaller or equal to this value. Use the LOG_* constants as a guide. `s` or `s; args` are the text that is outputted. The second one is first formatted using the array `args` .

aLog | DanielPharos - 20 Sep 2008 | [ Top ]

    Procedure aLog(logger: TLogName; s: string);
This procedure actually outputs the log-line. This procedure cannot be called from outside this module; use `Log` for that.

GetPatchVersion | DanielPharos - 20 Sep 2008 | [ Top ]

    function GetPatchVersion: String;
This procedure retrieves the patch version. This procedure is called from `OpenLogFile` , but doesn't return anything useful, since the patch-file construction is not used anymore.

Copyright (c) 2009, GNU General Public License by The QuArK (Quake Army Knife) Community - http://quark.sourceforge.net/ | [ Prev - Top - Next ]