- (re)enabled LogControl. The LogControlImpl singleton must be the first
[platform/upstream/libzypp.git] / zypp / base / LogControl.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/base/LogControl.h
10  *
11 */
12 #ifndef ZYPP_BASE_LOGCONTROL_H
13 #define ZYPP_BASE_LOGCONTROL_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/PtrTypes.h"
18 #include "zypp/Pathname.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23   ///////////////////////////////////////////////////////////////////
24   namespace base
25   { /////////////////////////////////////////////////////////////////
26
27     ///////////////////////////////////////////////////////////////////
28     //
29     //  CLASS NAME : LogControl
30     //
31     /** Maintain logfile related options.
32      * \note A Singleton using a Singleton implementation class,
33      * that's why there is no _pimpl like in other classes.
34     */
35     class LogControl
36     {
37       friend std::ostream & operator<<( std::ostream & str, const LogControl & obj );
38
39     public:
40       /** Singleton access. */
41       static LogControl instance()
42       { return LogControl(); }
43
44     public:
45       /** Return path to the logfile.
46        * An emty pathname for std::err.
47       */
48       const Pathname & logfile() const;
49
50       /** Set path for the logfile.
51        * An emty pathname for std::err.
52        * \throw if \a logfile_r is not usable.
53       */
54       void logfile( const Pathname & logfile_r );
55
56     public:
57       /** Turn on excessive logging for the lifetime of this object.*/
58       struct TmpExcessive
59       {
60         TmpExcessive();
61         ~TmpExcessive();
62       };
63
64     private:
65       /** Default ctor: Singleton */
66       LogControl()
67       {}
68     };
69     ///////////////////////////////////////////////////////////////////
70
71     /** \relates LogControl Stream output */
72     std::ostream & operator<<( std::ostream & str, const LogControl & obj );
73
74     /////////////////////////////////////////////////////////////////
75   } // namespace base
76   ///////////////////////////////////////////////////////////////////
77   /////////////////////////////////////////////////////////////////
78 } // namespace zypp
79 ///////////////////////////////////////////////////////////////////
80 #endif // ZYPP_BASE_LOGCONTROL_H