* @brief iLogger interface implementation
* @author Enar Vaikene
*
- * Copyright (c) 2011 Enar Vaikene
+ * Copyright (c) 2011-2012 Enar Vaikene
*
* This file is part of the eVaf C++ cross-platform application development framework.
*
/**
* Initializes the source
* @param source Name of the source
- * @param logDir Full path to the log directory
- * @param etcDir Full path to the configuration files directory
*
* This function initializes the newly created logger source and sets initial
* parameters for the source.
* Example logger.ini file:
* @code
* [.default]
- * severity = Fatal
- * maxSize = 100
- * maxCount = 3
+ * log_level = Fatal
+ * log_size = 100
+ * log_count = 3
*
* [my-source]
- * severity = Warning
- * maxSize = 1000
- * maxCount = 10
+ * log_level = Warning
+ * log_size = 1000
+ * log_count = 10
* @endcode
*/
- void init(QString const & source, QString const & logDir, QString const & etcDir);
+ void init(QString const & source);
public: // Members (we don't bother adding getter/setter functions)
+ /// Name of the source
+ QString name;
+
/// Current severity level
iLogger::Severity severity;
- /// Current log file name
+ /// File name
QString fileName;
/// Current maximum size of log files
virtual ~Logger();
/**
- * Initializes the interface implementation
+ * Initializes the iLogger interface implementation
* @return True if ok; false if initialization failed
*/
bool init();
iLogger interface
*/
- virtual QString defaultSource() const { return mDefaultSource; }
+ virtual QString defaultSource() const;
virtual void setDefaultSource(QString const & source);
private: // Members
+ /// Flag indicating that logger is fully initialized
+ bool mReady;
+
/// Current fatal error message handler
FatalMsgHandler mFatalMsgHandler;
/// Console output severity level
iLogger::Severity mConsoleSeverity;
- /// Current default source (defaults to "evaf")
- QString mDefaultSource;
+ /// Default logger source
+ QExplicitlySharedDataPointer<LoggerSource> mDefaultSource;
- /// Logger sources
+ /// Other logger sources
QHash<QString, QExplicitlySharedDataPointer<LoggerSource> > mSources;
/// Worker thread
private: // Methods
/// Returns the source by the name. The source is created if it does not exist yet.
- LoggerSource * getSource(QString const & name);
+ LoggerSource * getSource(QString const & name = QString());
#ifdef Q_OS_WIN32
/// Changes text colors on the Windows console