Public Member Functions | |
virtual rdaLogger * | createLogger (const char *name)=0 |
Creates a logger object. | |
virtual rdaLogger * | createAuditLogger (const char *name) |
Creates an audit logger object. | |
virtual const char * | getType ()=0 |
Returns a string identifier of the underlying logging mechanism. | |
virtual void | destroy () |
Closes the logging system and releases all related resources. |
This is an abstract base class for various concrete logger factories. By implementing your own logger class and a corresponding logger factory you can connect the RDA logging API to a system specific message logging mechanism.
To do this, you will need to provide implementations for the three abstract methods defined in the RDA base classes: log , createLogger , and getType . For example:
class MyLogger : public rdaLogger { protected: virtual void log(LogLevel level, const char* message) { if (isLoggable(level)) { // Send the message to the user specific logging mechanism } } }; class MyLoggerFactory : public rdaLoggerFactory { public: virtual rdaLogger* createLogger(const char* name) { return new MyLogger(name); } virtual const char* getType() { return "my logging mechanism"; } };
To redirect the log output to the specific mechanism, you will need to put the following code in the initialization part of your application, typically in main()
.
..... MyLoggerFactory* factory = new MyLoggerFactory; rdaLogger::init(*factory); // // Now we can use RDA loggers. // The log output will go to the user specific logging mechanism. // rdaLogger* log = rdaLogger::getLogger("opc"); log->info("Initializing OPC gateway"); .....
|
Closes the logging system and releases all related resources. Called from static rdaLogger::destroy(). |