]> vaikene.ee Git - evaf/blobdiff - src/libs/Common/logger.h
Changes and fixes to the iLogger interface:
[evaf] / src / libs / Common / logger.h
index 1dfdc62408a805f0ed985b93b36eb638898bbdc8..6e49ef723bcbd621fb65206045a1e671d4ff889c 100644 (file)
@@ -3,7 +3,7 @@
  * @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.
  *
@@ -54,8 +54,6 @@ public:
     /**
      * 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.
@@ -73,25 +71,28 @@ public:
      * 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
@@ -142,7 +143,7 @@ public:
     virtual ~Logger();
 
     /**
-     * Initializes the interface implementation
+     * Initializes the iLogger interface implementation
      * @return True if ok; false if initialization failed
      */
     bool init();
@@ -151,7 +152,7 @@ public:
         iLogger interface
     */
 
-    virtual QString defaultSource() const { return mDefaultSource; }
+    virtual QString defaultSource() const;
 
     virtual void setDefaultSource(QString const & source);
 
@@ -187,16 +188,19 @@ signals:
 
 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
@@ -209,7 +213,7 @@ private: // Members
 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