1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/HistoryLog.h
12 #ifndef ZYPP_TARGET_COMMITLOG_H
13 #define ZYPP_TARGET_COMMITLOG_H
17 #include "zypp/Pathname.h"
24 struct HistoryActionID
26 static const HistoryActionID NONE;
28 static const HistoryActionID INSTALL;
29 static const HistoryActionID REMOVE;
30 static const HistoryActionID REPO_ADD;
31 static const HistoryActionID REPO_REMOVE;
32 static const HistoryActionID REPO_CHANGE_ALIAS;
33 static const HistoryActionID REPO_CHANGE_URL;
47 HistoryActionID() : _id(NONE_e) {}
49 HistoryActionID(ID id) : _id(id) {}
51 explicit HistoryActionID(const std::string & strval_r);
53 ID toEnum() const { return _id; }
55 HistoryActionID::ID parse(const std::string & strval_r);
57 const std::string & asString(bool pad = false) const;
62 /** \relates HistoryActionID */
63 std::ostream & operator << (std::ostream & str, const HistoryActionID & id);
65 ///////////////////////////////////////////////////////////////////
67 // CLASS NAME : HistoryLog
69 * Simple wrapper for progress log. Refcnt, filename and corresponding
70 * ofstream are static members. Logfile constructor raises, destructor
71 * lowers refcounter. On refcounter changing from 0->1, file is opened.
72 * Changing from 1->0 the file is closed. Thus Logfile objects should be
73 * local to those functions, writing the log, and must not be stored
82 * HistoryLog().install(pi);
84 * HistoryLog().comment(someMessage);
88 * \note Take care to set proper target root dir if needed. Either pass
89 * it via the constructor, or set it via setRoot(Pathname) method.
90 * The default location of the file is determined by
91 * \ref ZConfig::historyLogPath() which defaults to
92 * /var/log/zypp/history.
96 HistoryLog( const HistoryLog & );
97 HistoryLog & operator=( const HistoryLog & );
99 static std::ofstream _log;
100 static unsigned _refcnt;
101 static Pathname _fname;
102 static const char _sep;
104 static void openLog();
105 static void closeLog();
107 static void refDown();
110 HistoryLog( const Pathname & rootdir = Pathname() );
114 static void setRoot( const Pathname & root );
115 static const Pathname & fname();
117 void comment( const std::string & comment, bool timestamp = false );
118 void install( const PoolItem & pi );
119 void remove( const PoolItem & pi );
121 void addRepository( const RepoInfo & repo );
122 void removeRepository( const RepoInfo & repo );
123 void modifyRepository( const RepoInfo & oldrepo, const RepoInfo & newrepo );
125 ///////////////////////////////////////////////////////////////////
129 #endif // ZYPP_TARGET_COMMITLOG_H