LightSaber Log

The debug messages shown by the classic LogMessage and OutputDebugString are good only during debugging as they are only visible to the person that debugs the program. If you want to show messages also to the end user, use the logging system provided by my LightSaber library: GabrielMoraru.com/my-delphi-code/delphi-libraries/lightsaber-log

The LightSaber Log is a simple but effective visual log control. The programmer can send messages to a log window from anywhere in the code. The user can also choose to hide unimportant messages via the Verbosity property.

This logging system is built into your application and does not require the end user to install a log viewer.

It has an “in RAM” memory logger (TRamLog) that can be used in a console application but that can also be hooked to a visual component (TLogGrid).

Global Log

For commodity, you can call CreateLogForm function in FormLog.pas to automatically create the global Log form, at application startup. This allows us to have one single log window per application that receives messages from the entire application.

Its form can be set to pop up automatically when an error is sent to the log (otherwise it stays hidden).

But the log can be also used “locally” for a single form.

The non-visual log (TRamLog)

This class is for CLI (command line interface) programs. During a batch job, your Delphi code can send data to the non-visual log. If no visual log is connected to RamLog, its output can be displayed at the console or saved to disk.

The visual log (TRichLog)

If we connect a visual log (TRichLog or the newer and better TLogGrid) to the RamLog, the messages are shown in real time, as the batch job progresses.

Verbosity level

TRamLog support several verbosity levels (verbose, info, warnings, errors, etc).
The log shows only the messages that are equal or above the specified verbosity threshold.
For example, if the log is set to show only warnings and errors and we send a message marked as “verbose”, then the messages will not be shown.

Each verbosity level is shown in a predefined color.

Verbosity filter

The user has control over which messages he wants to see (filter out verbose messages from the view). 

I/O

The log can be saved to disk to a binary file via a simple call to SaveToStream / LoadFromStream. You can easily adapt it to save to a DB or other storage. It can also save the log as RTF (color text).

Demo code available at GitHub.com/GabrielOnDelphi/GUI-AutoSave .

Scroll to Top