4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief FileTarget public header */
31 #ifndef HH_SENF_Utils_Logger_FileTarget_
32 #define HH_SENF_Utils_Logger_FileTarget_ 1
35 #include <boost/utility.hpp>
36 #include <boost/shared_ptr.hpp>
38 #include "IOStreamTarget.hh"
40 //#include "FileTarget.mpp"
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 namespace console { class DirectoryNode; }
49 /** \brief Log target writing to a %log file.
51 The FileTarget will save all %log messages in the given file. Messages will be appended at
55 senf::log::FileTarget target ("file.name");
57 // Route all messages to this file.
61 After %log files have been rotated, the reopen() member should be called to create a new %log
67 : private boost::base_from_member<std::ofstream>,
70 typedef boost::base_from_member<std::ofstream> ofstream_t;
73 //-////////////////////////////////////////////////////////////////////////
74 ///\name Structors and default members
77 explicit FileTarget(std::string const & filename, std::string const & nodename = "");
78 ///< Construct FileTarget writing to \a file
81 //-////////////////////////////////////////////////////////////////////////
83 void reopen(); ///< Reopen %log after log-file rotation
84 void reopen(std::string const & file); ///< Reopen %log under a new name
86 std::string const & filename() const; ///< Return current log file name
91 struct RegisterConsole {
93 static boost::shared_ptr<senf::console::DirectoryNode> create(
94 std::string const & filename, std::string const & nodename);
95 static RegisterConsole instance;
101 //-/////////////////////////////////////////////////////////////////////////////////////////////////
102 //#include "FileTarget.cci"
103 //#include "FileTarget.ct"
104 //#include "FileTarget.cti"
111 // comment-column: 40
112 // c-file-style: "senf"
113 // indent-tabs-mode: nil
114 // ispell-local-dictionary: "american"
115 // compile-command: "scons -u test"