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.
The Log window can be set to automatically pop up, but only on error messages.
The non-visual log (TRamLog)
This class is for CLI (command line interface) programs.
The idea is that your Delphi objects can send data to the non-visual log, during a batch job. At the end of the job, all collected messages can be shown in the visual log or at the console.
The visual log (TRichLog)
If we connect the TRamLog to the visual log (TRichLog), the messages are shown in real time, as the batch job progresses.
For your commodity, you can call CreateLogForm function in FormLog.pas at application startup. This allows us to have one single log window per application that receives messages from the entire application.
Both classes above support several verbosity levels (verbose, info, warnings, errors, etc).
The log receives only messages that are 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.
The log can be saved to disk to a binary file, so it can be restored on the next app startup.
Demo code available at GitHub.com/GabrielOnDelphi/GUI-AutoSave .