Merge pull request #249 from ramielrowe/multiprocess_logging
Fixing logging
This commit is contained in:
commit
24a5abf79a
@ -86,19 +86,19 @@ def get_logger(name=None, is_parent=True):
|
||||
def warn(msg, name=None):
|
||||
if name is None:
|
||||
name = default_logger_name
|
||||
get_logger(name=name).warn(msg)
|
||||
get_logger(name=name, is_parent=False).warn(msg)
|
||||
|
||||
|
||||
def error(msg, name=None):
|
||||
if name is None:
|
||||
name = default_logger_name
|
||||
get_logger(name=name).error(msg)
|
||||
get_logger(name=name, is_parent=False).error(msg)
|
||||
|
||||
|
||||
def info(msg, name=None):
|
||||
if name is None:
|
||||
name = default_logger_name
|
||||
get_logger(name=name).info(msg)
|
||||
get_logger(name=name, is_parent=False).info(msg)
|
||||
|
||||
|
||||
def _create_timed_rotating_logger(name):
|
||||
|
@ -1,5 +1,11 @@
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
from stacktach import stacklog
|
||||
|
||||
stacklog.set_default_logger_name('stacktach-web')
|
||||
web_logger = stacklog.get_logger('stacktach-web')
|
||||
web_logger_listener = stacklog.LogListener(web_logger)
|
||||
web_logger_listener.start()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', 'stacktach.views.welcome', name='welcome'),
|
||||
|
@ -47,6 +47,9 @@ setup_environment()
|
||||
from stacktach import stacklog
|
||||
|
||||
stacklog.set_default_logger_location("/tmp/%s.log")
|
||||
default_logger = stacklog.get_logger()
|
||||
worker_logger = stacklog.get_logger('worker')
|
||||
verifier_logger = stacklog.get_logger('verifier')
|
||||
|
||||
|
||||
class _AssertRaisesContext(object):
|
||||
|
@ -33,7 +33,7 @@ class StacklogTestCase(StacktachBaseTestCase):
|
||||
|
||||
def test_get_logger_should_use_default_name_when_name_not_specified(self):
|
||||
logger = stacklog.get_logger(None, is_parent=True)
|
||||
self.assertEquals(logger.name, 'stacktach-default')
|
||||
self.assertEquals(logger.name, stacklog.default_logger_name)
|
||||
|
||||
stacklog.set_default_logger_name('default')
|
||||
logger = stacklog.get_logger(None, is_parent=True)
|
||||
|
@ -302,9 +302,11 @@ class StacktachUsageParsingTestCase(StacktachBaseTestCase):
|
||||
|
||||
def setup_mock_log(self, name=None):
|
||||
if name is None:
|
||||
stacklog.get_logger(name=mox.IgnoreArg()).AndReturn(self.log)
|
||||
stacklog.get_logger(name=mox.IgnoreArg(),
|
||||
is_parent=False).AndReturn(self.log)
|
||||
else:
|
||||
stacklog.get_logger(name=name).AndReturn(self.log)
|
||||
stacklog.get_logger(name=name,
|
||||
is_parent=False).AndReturn(self.log)
|
||||
|
||||
def test_all_instance_events_have_mapping(self):
|
||||
for key, value in views.INSTANCE_EVENT.items():
|
||||
|
@ -59,9 +59,10 @@ class StacktachDBTestCase(StacktachBaseTestCase):
|
||||
|
||||
def setup_mock_log(self, name=None):
|
||||
if name is None:
|
||||
stacklog.get_logger(name=mox.IgnoreArg()).AndReturn(self.log)
|
||||
stacklog.get_logger(name=mox.IgnoreArg(),
|
||||
is_parent=False).AndReturn(self.log)
|
||||
else:
|
||||
stacklog.get_logger(name=name).AndReturn(self.log)
|
||||
stacklog.get_logger(name=name, is_parent=False).AndReturn(self.log)
|
||||
|
||||
def test_safe_get(self):
|
||||
Model = self.mox.CreateMockAnything()
|
||||
|
@ -42,6 +42,8 @@ from django.core import exceptions
|
||||
from verifier import WrongTypeException
|
||||
from stacktach import stacklog
|
||||
|
||||
stacklog.set_default_logger_name('verifier')
|
||||
|
||||
|
||||
def _get_child_logger():
|
||||
return stacklog.get_logger('verifier', is_parent=False)
|
||||
|
@ -41,6 +41,8 @@ from stacktach import stacklog
|
||||
from stacktach import message_service
|
||||
import datetime
|
||||
|
||||
stacklog.set_default_logger_name('verifier')
|
||||
|
||||
|
||||
def _get_child_logger():
|
||||
return stacklog.get_logger('verifier', is_parent=False)
|
||||
|
@ -42,6 +42,8 @@ from verifier import NotFound
|
||||
from verifier import VerificationException
|
||||
from stacktach import message_service
|
||||
|
||||
stacklog.set_default_logger_name('verifier')
|
||||
|
||||
|
||||
def _get_child_logger():
|
||||
return stacklog.get_logger('verifier', is_parent=False)
|
||||
|
@ -44,7 +44,7 @@ except ImportError:
|
||||
process = None
|
||||
log_listener = None
|
||||
processes = []
|
||||
|
||||
stacklog.set_default_logger_name('verifier')
|
||||
|
||||
def _get_parent_logger():
|
||||
return stacklog.get_logger('verifier', is_parent=True)
|
||||
|
@ -17,6 +17,7 @@ from worker import config
|
||||
|
||||
processes = []
|
||||
log_listener = None
|
||||
stacklog.set_default_logger_name('worker')
|
||||
|
||||
|
||||
def _get_parent_logger():
|
||||
|
@ -39,6 +39,8 @@ from stacktach import message_service
|
||||
from stacktach import stacklog
|
||||
from stacktach import views
|
||||
|
||||
stacklog.set_default_logger_name('worker')
|
||||
|
||||
|
||||
def _get_child_logger():
|
||||
return stacklog.get_logger('worker', is_parent=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user