My task is to create a class which will gather user activity around several applications.
Let’s say I have a class TLogging and a global object called Logging.
User activity (screen open, etc…) should be collected in memory (maybe put into a (string)list of TLogging) and saved into log file after some time interval (each 10 minutes), or when application is closed.
The most important is that logging must be in “silent mode”, it mustn’t affect user workflow in any way: no screen hanging, no exceptions.
Please give me the direction for this task.
This is a very broad question that touches several areas. A few hints:
At least consider an established logging framework for this. Newer Delphi versions come with CodeSite. SmartInspect is another alternative.
Use synchronization primitives to make your class thread-safe: TCriticalSection, TMREWSync
Make sure you understand the issues involved in multithreading and synchronization before attempting to write a thread-safe logging framework. A good start is Martin Harvey’s guide Multithreading – The Delphi Way.
Use a background thread that flushes the log content to disk in regular intervals or if enough data has been buffered.
Ask more specific questions here on SO if you encounter specific problems.