- Prepared class base::LogControl: Interface to logger, for
[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     namespace logger
28     {
29       class LogControlImpl;
30     }
31
32     ///////////////////////////////////////////////////////////////////
33     //
34     //  CLASS NAME : LogControl
35     //
36     /** Maintain logfile related options.
37      * Singleton
38     */
39     class LogControl
40     {
41       friend std::ostream & operator<<( std::ostream & str, const LogControl & obj );
42       typedef logger::LogControlImpl Impl;
43
44     public:
45       /** Singleton access. */
46       static LogControl instance();
47       /** Dtor */
48       ~LogControl();
49
50     public:
51       /** Return path to the logfile.
52        * An emty pathname for std::err.
53       */
54       const Pathname & logfile() const;
55
56       /** Set path for the logfile.
57        * An emty pathname for std::err.
58        * \throw if \a logfile_r is not usable.
59       */
60       void logfile( const Pathname & logfile_r );
61
62     public:
63       /** Turn on excessive logging for the lifetime of this object.*/
64       struct TmpExcessive
65       {
66         TmpExcessive();
67         ~TmpExcessive();
68       };
69
70     private:
71       /** Default ctor: Singleton*/
72       LogControl();
73        /** Pointer to implementation */
74       RW_pointer<Impl> _pimpl;
75     };
76     ///////////////////////////////////////////////////////////////////
77
78     /** \relates LogControl Stream output */
79     std::ostream & operator<<( std::ostream & str, const LogControl & obj );
80
81     /////////////////////////////////////////////////////////////////
82   } // namespace base
83   ///////////////////////////////////////////////////////////////////
84   /////////////////////////////////////////////////////////////////
85 } // namespace zypp
86 ///////////////////////////////////////////////////////////////////
87 #endif // ZYPP_BASE_LOGCONTROL_H