Missing files ...
[senf.git] / Utils / Logger / FileTarget.hh
index a6fac2b..5a80a7a 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer NETwork research (NET)
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 /** \file
     \brief FileTarget public header */
 
-#ifndef HH_FileTarget_
-#define HH_FileTarget_ 1
+#ifndef HH_SENF_Utils_Logger_FileTarget_
+#define HH_SENF_Utils_Logger_FileTarget_ 1
 
 // Custom includes
 #include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
 #include <fstream>
 #include "IOStreamTarget.hh"
 
 ///////////////////////////////hh.p////////////////////////////////////////
 
 namespace senf {
+
+    namespace console { class DirectoryNode; }
+
 namespace log {
 
-    /** \brief Log target writing to a log file.
+    /** \brief Log target writing to a %log file.
 
-        The FileTarget will save all log messages in the given file. Messages will be appended at
+        The FileTarget will save all %log messages in the given file. Messages will be appended at
         the end of the file.
 
-        After log files have been rotated, the reopen() member should be called to create a new log
+        \code
+        senf::log::FileTarget target ("file.name");
+        
+        // Route all messages to this file.
+        target.route();
+        \endcode
+
+        After %log files have been rotated, the reopen() member should be called to create a new %log
         file.
 
         \ingroup targets
@@ -58,16 +69,26 @@ namespace log {
         ///\name Structors and default members
         ///@{
 
-        explicit FileTarget(std::string file); ///< Construct FileTarget writing to \a file
+        explicit FileTarget(std::string const & filename, std::string const & nodename = ""); 
+                                        ///< Construct FileTarget writing to \a file
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
 
-        void reopen();                  ///< Reopen log after log-file rotation
-        void reopen(std::string file);  ///< Reopen log under a new name
+        void reopen();                  ///< Reopen %log after log-file rotation
+        void reopen(std::string const & file);  ///< Reopen %log under a new name
+
+        std::string const & filename() const; ///< Return current log file name
 
     private:
         std::string file_;
+
+        struct RegisterConsole {
+            RegisterConsole();
+            static boost::shared_ptr<senf::console::DirectoryNode> create(
+                std::string const & filename, std::string const & nodename);
+            static RegisterConsole instance;
+        };
     };
 
 }}