Use incremental numbers to avoid double logs, nicer
than timestamps.
This commit is contained in:
parent
2a47190f28
commit
3dd77cdd0b
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import gobject
|
import gobject
|
||||||
@ -101,9 +100,10 @@ def get_command(activity, activity_id=None, object_id=None, uri=None):
|
|||||||
return command
|
return command
|
||||||
|
|
||||||
def open_log_file(activity, activity_id):
|
def open_log_file(activity, activity_id):
|
||||||
timestamp = str(int(time.time()))
|
for i in range(1, 100):
|
||||||
name = '%s-%s.log' % (activity.bundle_id, timestamp)
|
path = env.get_logs_path('%s-%s.log' % (activity.bundle_id, i))
|
||||||
return open(env.get_logs_path(name), 'w')
|
if not os.path.exists(path):
|
||||||
|
return open(path, 'w')
|
||||||
|
|
||||||
class ActivityCreationHandler(gobject.GObject):
|
class ActivityCreationHandler(gobject.GObject):
|
||||||
"""Sugar-side activity creation interface
|
"""Sugar-side activity creation interface
|
||||||
|
@ -48,8 +48,5 @@ def start(log_filename=None):
|
|||||||
log_path = os.path.join(get_logs_dir(), log_filename + '.log')
|
log_path = os.path.join(get_logs_dir(), log_filename + '.log')
|
||||||
log_file = open(log_path, 'w')
|
log_file = open(log_path, 'w')
|
||||||
|
|
||||||
handler = logging.StreamHandler()
|
|
||||||
logging.getLogger('').addHandler(handler)
|
|
||||||
|
|
||||||
os.dup2(log_file.fileno(), sys.stdout.fileno())
|
os.dup2(log_file.fileno(), sys.stdout.fileno())
|
||||||
os.dup2(log_file.fileno(), sys.stderr.fileno())
|
os.dup2(log_file.fileno(), sys.stderr.fileno())
|
||||||
|
Loading…
Reference in New Issue
Block a user