Cleanup the logs stuff a bit.

This commit is contained in:
Marco Pesenti Gritti
2007-10-09 21:18:54 +02:00
parent b44a2916ba
commit 46d128c85a
6 changed files with 75 additions and 10 deletions
+5 -7
View File
@@ -18,7 +18,7 @@
import logging
import subprocess
import signal
import time
import dbus
import gobject
@@ -28,13 +28,11 @@ from sugar.presence import presenceservice
from sugar.activity.activityhandle import ActivityHandle
from sugar.activity import registry
from sugar.datastore import datastore
from sugar import logger
from sugar import util
from sugar import env
import os
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
# #3903 - this constant can be removed and assumed to be 1 when dbus-python
# 0.82.3 is the only version used
if dbus.version >= (0, 82, 3):
@@ -103,9 +101,9 @@ def get_command(activity, activity_id=None, object_id=None, uri=None):
return command
def open_log_file(activity, activity_id):
name = '%s-%s.log' % (activity.bundle_id, activity_id[:5])
path = os.path.join(logger.get_logs_dir(), name)
return open(path, 'w')
timestamp = str(int(time.time()))
name = '%s-%s.log' % (activity.bundle_id, timestamp)
return open(env.get_logs_path(name), 'w')
class ActivityCreationHandler(gobject.GObject):
"""Sugar-side activity creation interface
+7
View File
@@ -64,6 +64,13 @@ def get_profile_path(path=None):
else:
return base
def get_logs_path(path=None):
base = get_profile_path('logs')
if path != None:
return os.path.join(base, path)
else:
return base
def get_user_activities_path():
return os.path.expanduser('~/Activities')
+1 -1
View File
@@ -67,7 +67,7 @@ def set_level(level):
if levels.has_key(level):
logging.getLogger('').setLevel(levels[level])
def start(log_filename=None, redirect_io=True):
def start(log_filename=None, redirect_io=False):
if os.environ.has_key('SUGAR_LOGGER_LEVEL'):
set_level(os.environ['SUGAR_LOGGER_LEVEL'])