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 ///////////////////////////////////////////////////////////////////
26 // CLASS NAME : HistoryLog
28 * Simple wrapper for progress log. Refcnt, filename and corresponding
29 * ofstream are static members. Logfile constructor raises, destructor
30 * lowers refcounter. On refcounter changing from 0->1, file is opened.
31 * Changing from 1->0 the file is closed. Thus Logfile objects should be
32 * local to those functions, writing the log, and must not be stored
41 * HistoryLog().install(pi);
43 * HistoryLog().comment(someMessage);
47 * \note Take care to set proper target root dir if needed. Either pass
48 * it via the constructor, or set it via setRoot(Pathname) method.
49 * The default location of the file is determined by
50 * \ref ZConfig::historyLogPath() which defaults to
51 * /var/log/zypp/history.
53 * \see http://en.opensuse.org/Libzypp/Package_History
55 * \todo The implementation as pseudo signleton is questionable.
56 * Use shared_ptr instead of handcrafted ref/unref. Manage multiple
57 * logs at different locations.
61 HistoryLog( const HistoryLog & );
62 HistoryLog & operator=( const HistoryLog & );
65 * Constructor with an optional root directory.
67 * \param rootdir actual target root directory
69 HistoryLog( const Pathname & rootdir = Pathname() );
73 * Set new root directory to the default history log file path.
75 * This path will be prepended to the default log file path. This should
76 * be done where there is a potential that the target root has changed.
78 * \param root new root directory.
80 static void setRoot( const Pathname & root );
83 * Get the current log file path.
85 static const Pathname & fname();
88 * Log a comment (even multiline).
90 * \param comment the comment
91 * \param timestamp whether to include a timestamp at the start of the comment
93 void comment( const std::string & comment, bool timestamp = false );
96 * Log installation (or update) of a package.
98 void install( const PoolItem & pi );
101 * Log removal of a package
103 void remove( const PoolItem & pi );
106 * Log a newly added repository.
108 * \param repo info about the added repository
110 void addRepository( const RepoInfo & repo );
113 * Log recently removed repository.
115 * \param repo info about the removed repository
117 void removeRepository( const RepoInfo & repo );
120 * Log certain modifications to a repository.
122 * \param oldrepo info about the old repository
123 * \param newrepo info about the new repository
125 void modifyRepository( const RepoInfo & oldrepo, const RepoInfo & newrepo );
127 ///////////////////////////////////////////////////////////////////
131 #endif // ZYPP_TARGET_COMMITLOG_H