Provides a log framework.

LazLogger.pas provides logging facilities to write message to a file. Messages can be logged plain, or enclosed in begin/end like blocks, adding indent to all messages between to points (blocks can be nested). It also has the ability to filter groups of messages.

It can reads the command line and environment to find the desired filename. By default it looks for --debug-log= on the command line or "appname"_debuglog in environment.

If no log name is found StdOut is used.

The easiest method is to use the unit and put "DebugLn"/ "DbgOut" / "DebugLnEnter"/ "DebugLnExit" in your code. This works without any further setup.

This file is part of the LazUtils package.

Writes a message to the log.

Writes the text to the log. Does not append a new line. The Argument can be:

  • One or more string(s)
  • An open array of const: All values are converted to string and joined
  • A single string and open array of const: Will be passed to Format
  • Any of the above with a PLazLoggerLogGroup as filter

This is a forwarder to the log TLazLogger object. See there for details.

GetDebugLogger SetDebugLogger
Writes a message to the log.

Writes the text to the log. Does append a new line.

The Argument can be:

  • One or more string
  • An open array of const: All values are converted to string and joined
  • A single string and open array of const: Will be passed to Format
  • Any of the above with a PLazLoggerLogGroup as filter

This is a forwarder to the log TLazLogger object. See there for details.

GetDebugLogger SetDebugLogger
Writes a message to the log.

Writes the text to the log. Does append a new line. Increases the current intend.

The Argument can be:

  • One or more string
  • An open array of const: All values are converted to string and joined
  • A single string and open array of const: Will be passed to Format
  • Any of the above with a PLazLoggerLogGroup as filter

This is a forwarder to the log TLazLogger object. See there for details.

GetDebugLogger SetDebugLogger
Writes a message to the log.

Writes the text to the log. Does append a new line. Increases the current intend.

The Argument can be:

  • One or more string
  • An open array of const: All values are converted to string and joined
  • A single string and open array of const: Will be passed to Format
  • Any of the above with a PLazLoggerLogGroup as filter
  • This is a forwarder to the log TLazLogger object. See there for details.
GetDebugLogger SetDebugLogger
Create a text representation for the specified value.

Create a text representation for the specified value. Does not produce a log output.

A log file writer object.

Provides functionality to write messages to a log file. Allows filtering and changing indent level.

Can parse options from command line for log filename and filter settings.

An application can subclass the logger to add it's own functionality.

The name of the log file. This can be set by the application. Alternatively it can be determined according to ParamForLogFileName and EnvironmentForLogFileName Enable writing to STDOUT, if LogName is not set. Enable opening and closing the log for each write. Performs file operations using a critical section.

TLazLoggerFileHandleThreadSave is a TLazLoggerFileHandle descendant which implements a threaded file logger. TLazLoggerFileHandleThreadSave uses a TRTLCriticalSection class instance to lock the log file during file output operations. Requires that DoOpenFile is called by the main application thread. Otherwise the filehandle may get closed.

File operations are queued for the main thread.

TLazLoggerFileHandleMainThread is a TLazLoggerFileHandle descendant which implements a file-based logger which queues file operations for the main thread in an application.

TLazLoggerFile is a TLazLoggerWithGroupParam descendant. Name of the command line option, that has the logfile's name.

A param on the commandline, that may contain the name (if not already set) example/default: --debug-log=.

If LogName is empty and this is set, then the commandline will be checked for a parameter of the name specified. LogName will be set, if found. The default value is '--debug-log='. Note that the dashes and equal sign must be present.

Name of the environment, that has the logfile name.

If LogName is empty and con not be found from ParamForLogFileName, then the environment variable specified will be checked. LogName will be set, if found.

* will be replaced by param(0)

The default is: *_debuglog.

Event when writing a full line (Debugln, DebuglnEnter or DebuglnExit). The event contains the text to be logged. It also has a handled var param, that can be set to True to prevent default action (writing to log). Event when writing without line end (DbgOut).

The event contains the text to be logged. It also has a handled var param, that can be set to True to prevent default action (writing to log).

The name of the log file. This can be set by the application. Alternatively it can be determined according to ParamForLogFileName and EnvironmentForLogFileName Enable writing to STDOUT, if LogName is not set. Enable opening and closing the log for each write.