From 5634324b6525fd1f95d40e6ed4e3126ca55ce50a Mon Sep 17 00:00:00 2001 From: Johannes Winkelmann Date: Fri, 7 Apr 2006 07:49:13 +0000 Subject: [PATCH] prt-get: add timestamps to log files git-svn-id: https://crux.nu/svn/tools/prt-get/trunk@1170 0b5ae1c7-2405-0410-a7fc-ba219f786e1e --- ChangeLog | 2 ++ TODO | 3 ++- configure | 2 +- configure.in | 2 +- src/installtransaction.cpp | 25 +++++++++++++++++++++---- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index b642676..061f46b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ * 0.5.12 00.04.2006 Johannes Winkelmann +- Add 'depinst' in 'help' (thanks Simone) - Fix compilation on OpenBSD - Show alias info in depends - don't install alias file and deplist @@ -9,6 +10,7 @@ - print full add command and PACKAGE_DIR info when using install/update -v - Make 'cat' and 'readme' use $PAGER if set - update default prt-get.conf to reflect new port hierarchy (core/opt/contrib) +- add timestamps to log files * 0.5.11 29.05.2005 Johannes Winkelmann - add --path to 'ls' diff --git a/TODO b/TODO index 890830e..dc1f30a 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,8 @@ $PKGMK_PACKAGE_DIR` to determine PACKAGE_DIR - allow dependency injection for sysup, with previews - prefer toolchain (patch in trac) - dependent --list-orphaned; should simplify pkgfoster +- logging: check for non-root owned symlinks +- logging: reject relative logfile names ============================================================================== @@ -45,7 +47,6 @@ config: go through additional configuration options; add and/or replace - better reports (installed/failed/not even tried to install) [ ] message log for prt-get messages ? -[ ] timestamps for the log file [ ] --quiet mode; suppress output of pkgmk and pkgadd [ ] prt-get diff stats: "100 Packages with differences" diff --git a/configure b/configure index 8391623..744f2ad 100755 --- a/configure +++ b/configure @@ -1614,7 +1614,7 @@ fi # Define the identity of the package. PACKAGE=prt-get - VERSION=0.5.12pre + VERSION=0.5.12pre2 cat >>confdefs.h <<_ACEOF diff --git a/configure.in b/configure.in index 49bf314..cafe635 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT AC_CONFIG_SRCDIR([src/prtget.cpp]) -AM_INIT_AUTOMAKE(prt-get,0.5.12pre1) +AM_INIT_AUTOMAKE(prt-get,0.5.12pre2) dnl Determine default prefix diff --git a/src/installtransaction.cpp b/src/installtransaction.cpp index e75d1b8..c1f7718 100644 --- a/src/installtransaction.cpp +++ b/src/installtransaction.cpp @@ -18,6 +18,7 @@ #include #include #include +#include using namespace std; @@ -191,7 +192,13 @@ InstallTransaction::installPackage( const Package* package, int fdlog = -1; string logFile = ""; + string timestamp; + string commandName = "prt-get"; + if ( parser->wasCalledAsPrtCached() ) { + commandName = "prt-cache"; + } + if ( m_config->writeLog() ) { logFile = m_config->logFilePattern(); if ( logFile == "" ) { @@ -228,6 +235,12 @@ InstallTransaction::installPackage( const Package* package, if ( fdlog == -1 ) { return LOG_FILE_FAILURE; } + + time_t startTime; + time(&startTime); + timestamp = ctime(&startTime); + timestamp = commandName + ": starting build " + timestamp; + write( fdlog, timestamp.c_str(), timestamp.length()); } string pkgdir = package->path() + "/" + package->name(); @@ -304,10 +317,6 @@ InstallTransaction::installPackage( const Package* package, package->version() + "-" + package->release() + ".pkg.tar.gz"; - string commandName = "prt-get"; - if ( parser->wasCalledAsPrtCached() ) { - commandName = "prt-cache"; - } // - inform the user about what's happening string fullCommand = commandName + ": " + cmd + " " + args; @@ -328,9 +337,17 @@ InstallTransaction::installPackage( const Package* package, cout << fullCommand << endl; } if ( m_config->writeLog() ) { + time_t endTime; + time(&endTime); + timestamp = ctime(&endTime); + timestamp = commandName + ": build done " + timestamp; + write( fdlog, summary.c_str(), summary.length() ); + write( fdlog, "\n", 1 ); write( fdlog, fullCommand.c_str(), fullCommand.length() ); write( fdlog, "\n", 1 ); + write( fdlog, timestamp.c_str(), timestamp.length()); + write( fdlog, "\n", 1 ); } Process installProc( cmd, args, fdlog );