libzypp 9.41.1

zypp::HistoryLog Class Reference

Writing the zypp history fileReference counted signleton for writhing the zypp history file. More...

#include <HistoryLog.h>

List of all members.

Public Member Functions

 HistoryLog (const Pathname &rootdir=Pathname())
 Constructor with an optional root directory.
 ~HistoryLog ()
void comment (const std::string &comment, bool timestamp=false)
 Log a comment (even multiline).
void install (const PoolItem &pi)
 Log installation (or update) of a package.
void remove (const PoolItem &pi)
 Log removal of a package.
void addRepository (const RepoInfo &repo)
 Log a newly added repository.
void removeRepository (const RepoInfo &repo)
 Log recently removed repository.
void modifyRepository (const RepoInfo &oldrepo, const RepoInfo &newrepo)
 Log certain modifications to a repository.

Static Public Member Functions

static void setRoot (const Pathname &root)
 Set new root directory to the default history log file path.
static const Pathname & fname ()
 Get the current log file path.

Private Member Functions

 HistoryLog (const HistoryLog &)
HistoryLogoperator= (const HistoryLog &)

Detailed Description

Writing the zypp history file

Reference counted signleton for writhing the zypp history file.

The history file is opened on demand and closed when the last HistoryLog object drops its reference. Thus HistoryLog objects should be local to those functions, writing the log, and must not be stored permanently.

 some method ()
 {
   PoolItem pi;
   ...
   HistoryLog().install(pi);
   ...
   HistoryLog().comment(someMessage);
 }
Note:
Take care to set proper target root dir if needed. Either pass it via the constructor, or set it via setRoot(Pathname) method. The default location of the file is determined by zypp::ZConfig::historyLogPath (default: /var/log/zypp/history).
Todo:
The implementation as pseudo signleton is questionable. Use shared_ptr instead of handcrafted ref/unref. Manage multiple logs at different locations.

Definition at line 55 of file HistoryLog.h.


Constructor & Destructor Documentation

zypp::HistoryLog::HistoryLog ( const HistoryLog ) [private]
zypp::HistoryLog::HistoryLog ( const Pathname &  rootdir = Pathname())

Constructor with an optional root directory.

Parameters:
rootdiractual target root directory

Definition at line 120 of file HistoryLog.cc.

References setRoot().

zypp::HistoryLog::~HistoryLog ( )

Definition at line 126 of file HistoryLog.cc.


Member Function Documentation

HistoryLog& zypp::HistoryLog::operator= ( const HistoryLog ) [private]
void zypp::HistoryLog::setRoot ( const Pathname &  root) [static]

Set new root directory to the default history log file path.

This path will be prepended to the default log file path. This should be done where there is a potential that the target root has changed.

Parameters:
rootnew root directory.

Definition at line 131 of file HistoryLog.cc.

References zypp::filesystem::assert_dir(), zypp::ZConfig::historyLogFile(), zypp::ZConfig::instance(), and MIL.

Referenced by HistoryLog(), and zypp::target::TargetImpl::TargetImpl().

const Pathname & zypp::HistoryLog::fname ( ) [static]

Get the current log file path.

Definition at line 147 of file HistoryLog.cc.

References zypp::ZConfig::historyLogFile(), and zypp::ZConfig::instance().

Referenced by zypp::target::TargetImpl::commit().

void zypp::HistoryLog::comment ( const std::string &  comment,
bool  timestamp = false 
)

Log a comment (even multiline).

Parameters:
commentthe comment
timestampwhether to include a timestamp at the start of the comment

Definition at line 156 of file HistoryLog.cc.

Referenced by zypp::target::rpm::RpmDb::doInstallPackage(), and zypp::target::rpm::RpmDb::doRemovePackage().

void zypp::HistoryLog::addRepository ( const RepoInfo repo)
void zypp::HistoryLog::removeRepository ( const RepoInfo repo)

Log recently removed repository.

Parameters:
repoinfo about the removed repository

Definition at line 257 of file HistoryLog.cc.

References zypp::repo::RepoInfoBase::alias(), zypp::HistoryActionID::asString(), zypp::str::escape(), zypp::ZConfig::instance(), zypp::HistoryActionID::REPO_REMOVE, and zypp::ZConfig::userData().

Referenced by zypp::RepoManager::removeRepository().

void zypp::HistoryLog::modifyRepository ( const RepoInfo oldrepo,
const RepoInfo newrepo 
)

Log certain modifications to a repository.

Parameters:
oldrepoinfo about the old repository
newrepoinfo about the new repository

Definition at line 268 of file HistoryLog.cc.

References zypp::repo::RepoInfoBase::alias(), zypp::HistoryActionID::asString(), zypp::RepoInfo::baseUrlsBegin(), zypp::str::escape(), zypp::ZConfig::instance(), zypp::HistoryActionID::REPO_CHANGE_ALIAS, zypp::HistoryActionID::REPO_CHANGE_URL, and zypp::ZConfig::userData().

Referenced by zypp::RepoManager::modifyRepository().


The documentation for this class was generated from the following files: