Table of Contents

Namespace Tripous.Logging

Classes

FileLogListener

A log listener that writes log info to file(s).

NOTE: Applies retain policy. By default keeps log files 7 days old.

LogEntry

Represents a log message

LogEntryArgs

Provides data for an event that reports a log entry.

LogGlobalSettings

Global settings for the Logger class.

LogListener

A listener for LogEntry messages.

A listener registers itself automatically with Logger, upon construction.

This class provides retain policy related properties to inheritors.

LogRecord

Represents a log entry in a tabular form.

LogSource

Represents a named source in a log.

The Source and the Scope of a LogEntry are just names devised by the developer.

A Source could be the full name of a class, such as a MainForm, an action url or any other suitable string and it marks all the log messages produced by this source.

A Scope could be the name of a method or the name of a group of methods, or whatever.

The Logger class provides a method to create a Source.

The Source creates a Default Scope when it is created. The developer never gets a reference to a Scope.

The developer may call EnterScope(...) passing it a Scope name.

The ExitScope() exits the last entered Scope. The Default Scope cannot exited.

It is even safe to call ExitScope() more times than the existing Scopes.

Any call to Source log methods, such as Log(), Debug(), Error(), etc. produces a LogEntry marked with the Source name and the name of the latest Scope.

Logger

Represents an object that handles log information.

A code can instruct Logger to log a bit of information by calling one of the various Log() methods. Then the Logger notifies all ILogListener objects subscribed to it by calling the ILogListener.ProcessLog() of each one passing an LogInfo object that represents the log information.

The Logger doesn't actually logs the information in any medium. Instead it relies in that some one of its ILogListener subscribers is capable of doing that.

Any thread can call any of the Log() methods of the Logger.

CAUTION: The Logger calls its Listeners asynchronously, that is from inside a thread. Thus Listeners should synchronize the ProcessLog() call. Controls need to check if InvokeRequired.

SyncedLogListener

A log listener that synchronizes the ProcessLog(LogEntry) call to any context.

That is, it is safe to attach to the EntryEvent a GUI element such as a Form or a TextBox.

SEE: Post(SendOrPostCallback, object) which reverses the responsibility of thread synchronization.

Client code has just to link to EntryEvent and then process the passed LogEntry safely.

The LogEntry provides methods such as AsJson(), AsList(), etc. for getting a string representation of the entry.

SEE: https://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/

WriteLineFile

Helper used in writing to files, line by line.

It uses the fist line of a file as a column line, if one is passed.

Column names must be right padded with spaces according to a used line format.

A file may grow up to a defined maximum size (in kilobytes).

After that a new file is created.

The new file gets a name as yyyy-MM-dd_HH_mm_ss__fff_DefaultFileName

Enums

LogLevel

The level of log info to issue, display, or persist