Class ALoggingObject

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ALoggingObject = class(APrintingObject)

Description

This class represents a generic object that is capable of logging items to a given log. The base class does not create a log itself; it relies on the implementations of its descendants to do that. It does provide several utility methods that can be called by descendant implementations in order to log notes, hints, warnings, errors, and fatal errors.

Hierarchy

Overview

Fields

Protected MyLog: ALog;

Methods

Public function init: boolean; override;
Public function log(const items: array of const): TStreamIOSize; virtual;
Public function logNoteBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedNote; virtual;
Public function logHintBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedHint; virtual;
Public function logWarningBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedWarning; virtual;
Public function logErrorBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedError; virtual;
Public function logFatalErrorBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedFatalError; virtual;
Public function Log: ALog; virtual;

Description

Fields

Protected MyLog: ALog;

Refers to the log used by the instance to record status information and errors.

Methods

Public function init: boolean; override;

Initializer

Public function log(const items: array of const): TStreamIOSize; virtual;

Log the specified items to the log. This method is simply a pass-through method for ALog.print.

Public function logNoteBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedNote; virtual;

Log a note to the log.

This method constructs an instance of ALoggedNote, which is then logged. message and params are passed to the constructor for ALoggedNote.

If retain is True, then the instance of ALoggedNote constructed by this routine is returned to the caller; this allows the caller to both log the note and raise it as an exception with one statement:

        // Log a note and raise an error
        raise Self.logNoteBecause(noteExecutionReachedHere, []);
      

Otherwise, the note is freed and the call returns Nil.

Public function logHintBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedHint; virtual;

Log a hint to the log.

This method constructs an instance of ALoggedHint, which is then logged. message and params are passed to the constructor for ALoggedHint.

If retain is True, then the instance of ALoggedHint constructed by this routine is returned to the caller; this allows the caller to both log the hint and raise it as an exception with one statement:

        // Log a hint and raise an error
        raise Self.logHintBecause(hintExecutionReachedHere, []);
      

Otherwise, the hint is freed and the call returns Nil.

Public function logWarningBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedWarning; virtual;

Log a warning to the log.

This method constructs an instance of ALoggedWarning, which is then logged. message and params are passed to the constructor for ALoggedWarning.

If retain is True, then the instance of ALoggedWarning constructed by this routine is returned to the caller; this allows the caller to both log the warning and raise it as an exception with one statement:

        // Log a warning and raise an error
        raise Self.logWarningBecause(warnExecutionReachedHere, []);
      

Otherwise, the warning is freed and the call returns Nil.

Public function logErrorBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedError; virtual;

Log an error to the log.

This method constructs an instance of ALoggedError, which is then logged. message and params are passed to the constructor for ALoggedError.

If retain is True, then the instance of ALoggedError constructed by this routine is returned to the caller; this allows the caller to both log the error and raise it as an exception with one statement:

        // Log and raise an error
        raise Self.logErrorBecause(errExecutionReachedHere, []);
      

Otherwise, the error is freed and the call returns Nil.

Public function logFatalErrorBecause(const message: string; const params: array of const; const retain: boolean = false): ALoggedFatalError; virtual;

Log a fatal error to the log.

This method constructs an instance of ALoggedFatalError, which is then logged. message and params are passed to the constructor for ALoggedFatalError.

If retain is True, then the instance of ALoggedFatalError constructed by this routine is returned to the caller; this allows the caller to both log the error and raise it as an exception with one statement:

        // Log a hint and raise an error
        raise Self.logFatalErrorBecause(ferrExecutionReachedHere, []);
      

Otherwise, the error is freed and the call returns Nil.

Public function Log: ALog; virtual;

Retrieve a reference to the log used by the instance to log status messages and warnings. The caller should NOT attempt to free this reference.


Generated by PasDoc 0.13.0 on 2015-06-23 19:40:11