From 1a86efc39fe10d10baf2154281fe7977387f45ff Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 3 May 2011 12:34:31 -0700 Subject: [PATCH] timestamps and appending for import log (#155) --- NEWS | 4 ++++ beets/ui/commands.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2d4cc3c3e..e6646e7bc 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ ----- * Prompts in the importer interface are now colorized for easy reading. The default option is always highlighted. +* The import logger has been improved for "always-on" use. First, + it is now possible to specify a log file in .beetsconfig. Also, + logs are now appended rather than overwritten and contain + timestamps. * Fix crash when autotagging files with no metadata. 1.0b8 diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 49ce1bddc..4fcc810ab 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -19,6 +19,7 @@ from __future__ import with_statement # Python 2.5 import logging import sys import os +import time from beets import ui from beets.ui import print_ @@ -426,7 +427,8 @@ def import_files(lib, paths, copy, write, autot, logpath, art, threaded, # Open the log. if logpath: logpath = normpath(logpath) - logfile = open(syspath(logpath), 'w') + logfile = open(syspath(logpath), 'a') + print >>logfile, 'import started', time.asctime() else: logfile = None @@ -458,6 +460,7 @@ def import_files(lib, paths, copy, write, autot, logpath, art, threaded, # If we were logging, close the file. if logfile: + print >>logfile, '' logfile.close() # Emit event.