38 inline string timestamp()
41 inline string userAtHostname()
45 char * tmp = ::cuserid(buf);
49 if (!::gethostname(buf, 255))
50 result +=
"@" + string(buf);
55 static std::string pidAndAppname()
57 static std::string _val;
60 pid_t mypid = getpid();
66 _val += myname.basename();
71 static std::string cmdline()
73 static std::string _val;
76 pid_t mypid = getpid();
80 const char * sep =
"'";
81 while ( cmdlineStr && cmdlineStr.get( ch ) )
90 case '\0': _val +=
'\''; sep =
" '";
break;
91 case '\n': _val +=
' ';
break;
92 case '\\': _val +=
'\\'; _val +=
'\\';
break;
93 case '|': _val +=
'\\'; _val +=
'|';
break;
94 default: _val += ch;
break;
105 const char _sep =
'|';
107 unsigned _refcnt = 0;
109 Pathname _fnameLastFail;
111 inline void openLog()
113 if ( _fname.empty() )
117 _log.open( _fname.asString().c_str(), std::ios::out|std::ios::app );
118 if( !_log && _fnameLastFail != _fname )
120 ERR <<
"Could not open logfile '" << _fname <<
"'" << endl;
121 _fnameLastFail = _fname;
125 inline void closeLog()
138 inline void refDown()
165 if ( ! rootdir.absolute() )
173 MIL <<
"installation log file " << _fname << endl;
181 if ( _fname.empty() )
195 _log << timestamp() <<
" ";
197 const char * s = comment.c_str();
199 unsigned size = comment.size();
202 if (comment[size-1] ==
'\n')
205 for (
unsigned i = 0; i < size; ++i, ++c )
208 _log << string( s, c + 1 - s ) <<
"# ";
213 _log << std::string( s, c-s );
225 << _sep << userAtHostname()
242 << _sep << p->edition()
243 << _sep << p->arch();
247 _log << _sep << userAtHostname();
249 _log << _sep << pidAndAppname();
254 << _sep << p->repoInfo().alias()
255 << _sep << p->checksum().checksum()
271 << _sep << p->edition()
272 << _sep << p->arch();
276 _log << _sep << userAtHostname();
278 _log << _sep << pidAndAppname();
325 if ( oldrepo.
url() != newrepo.
url() )
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
std::string alias() const
unique identifier for this source.
static ZConfig & instance()
Singleton ctor.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
void stampCommand()
Log info about the current process.
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
static const HistoryActionID REMOVE
What is known about a repository.
static const HistoryActionID REPO_CHANGE_ALIAS
void install(const PoolItem &pi)
Log installation (or update) of a package.
static const HistoryActionID INSTALL
static const HistoryActionID STAMP_COMMAND
std::string asString() const
Returns a default string representation of the Url object.
Pathname historyLogFile() const
Path where ZYpp install history is logged.
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
void removeRepository(const RepoInfo &repo)
Log recently removed repository.
static const Pathname & fname()
Get the current log file path.
const std::string & asString(bool pad=false) const
static const HistoryActionID REPO_REMOVE
ResStatus & status() const
Returns the current status.
void addRepository(const RepoInfo &repo)
Log a newly added repository.
static const HistoryActionID REPO_CHANGE_URL
bool isByApplHigh() const
std::string numstring(char n, int w=0)
static void setRoot(const Pathname &root)
Set new root directory to the default history log file path.
std::string form(const std::string &format_r) const
Return string representation according to format as localtime.
static const HistoryActionID REPO_ADD
static Date now()
Return the current time.
void remove(const PoolItem &pi)
Log removal of a package.
std::string userData() const
User defined string value to be passed to log, history, plugins...
Url url() const
Pars pro toto: The first repository url.
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
Combining sat::Solvable and ResStatus.
void modifyRepository(const RepoInfo &oldrepo, const RepoInfo &newrepo)
Log certain modifications to a repository.
#define HISTORY_LOG_DATE_FORMAT
HistoryLog(const HistoryLog &)
TraitsType::constPtrType constPtr