예제 #1
0
 def test_local_basic(self):
     # logging to local file test
     name = 'local.basic'
     log = mlogging.config(name=name, outputs=['local'])
     log.warning('warning')
     log_file = os.path.join(self.local_root, name.replace('.', '/'))
     tail = subprocess.Popen(["tail", log_file], stdout=subprocess.PIPE)
     msg = get_linestring_split(tail.stdout.read(), -1)
     self.assertEqual(msg[3:6], [name, 'WARNING', 'warning'])
예제 #2
0
파일: test.py 프로젝트: A32/pycodemo
 def test_local_basic(self):
     # logging to local file test
     name = 'local.basic'
     log = mlogging.config(name=name, outputs=['local'])
     log.warning('warning')
     log_file = os.path.join(self.local_root, name.replace('.','/'))
     tail = subprocess.Popen(["tail",log_file], stdout=subprocess.PIPE)
     msg = get_linestring_split(tail.stdout.read(), -1)
     self.assertEqual(msg[3:6], [name,'WARNING','warning'])
예제 #3
0
파일: test.py 프로젝트: A32/pycodemo
 def test_screen_basic(self):
     # make sure logging to screen works
     name = 'screen.basic'
     log = mlogging.config(name=name, outputs=['screen'])
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[3:6], [name,'WARNING','warning'])
예제 #4
0
파일: test.py 프로젝트: A32/pycodemo
 def test_option(self):
     name = 'option.option1'
     log = mlogging.config(name=name, outputs=['screen'])
     mlogging.option(name, format_string='%(message)s')
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[0:1], ['warning'])
     name = 'option.option2'
     log = mlogging.config(name=name, outputs=['screen'])
     mlogging.option(name, format_string='%(levelname)s %(message)s')
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[0:2], ['WARNING','warning'])
예제 #5
0
파일: test.py 프로젝트: A32/pycodemo
 def test_set_default(self):
     mlogging.set_default(format_string='%(message)s')
     name = 'option.set_default'
     log = mlogging.config(name=name, outputs=['screen'])
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[0:1], ['warning'])
예제 #6
0
 def test_screen_basic(self):
     # make sure logging to screen works
     name = 'screen.basic'
     log = mlogging.config(name=name, outputs=['screen'])
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[3:6], [name, 'WARNING', 'warning'])
예제 #7
0
 def test_option(self):
     name = 'option.option1'
     log = mlogging.config(name=name, outputs=['screen'])
     mlogging.option(name, format_string='%(message)s')
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[0:1], ['warning'])
     name = 'option.option2'
     log = mlogging.config(name=name, outputs=['screen'])
     mlogging.option(name, format_string='%(levelname)s %(message)s')
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[0:2], ['WARNING', 'warning'])
예제 #8
0
 def test_set_default(self):
     mlogging.set_default(format_string='%(message)s')
     name = 'option.set_default'
     log = mlogging.config(name=name, outputs=['screen'])
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[0:1], ['warning'])
예제 #9
0
파일: test.py 프로젝트: A32/pycodemo
 def test_combine_basic(self):
     # test combined logging
     name = 'combine.basic'
     log = mlogging.config(name=name, outputs=['screen','local'])       
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     screen_msg = log_output.split()
     self.assertEqual(screen_msg[3:6], [name,'WARNING','warning'])
     log_file = os.path.join(self.local_root, name.replace('.','/'))
     tail = subprocess.Popen(["tail",log_file], stdout=subprocess.PIPE)
     msg_local =  get_linestring_split(tail.stdout.read(), -1)
     self.assertEqual(msg_local[3:6], [name,'WARNING','warning'])
예제 #10
0
 def test_combine_basic(self):
     # test combined logging
     name = 'combine.basic'
     log = mlogging.config(name=name, outputs=['screen', 'local'])
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.warning('warning')
     log_output = log.handlers[0].stream.getvalue()
     screen_msg = log_output.split()
     self.assertEqual(screen_msg[3:6], [name, 'WARNING', 'warning'])
     log_file = os.path.join(self.local_root, name.replace('.', '/'))
     tail = subprocess.Popen(["tail", log_file], stdout=subprocess.PIPE)
     msg_local = get_linestring_split(tail.stdout.read(), -1)
     self.assertEqual(msg_local[3:6], [name, 'WARNING', 'warning'])
예제 #11
0
파일: test.py 프로젝트: A32/pycodemo
 def test_screen_filter(self):
     # make sure logging to screen works
     name = 'screen.filter'
     log = mlogging.config(name=name, outputs=['screen'], levels=['warning','debug'])
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.critical('critical')
     log.error('error')
     log.warning('warning')
     log.info('info')
     log.debug('debug')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output,0)
     self.assertEqual(msg_warning[3:6], [name,'WARNING','warning'])
     msg_debug = get_linestring_split(log_output,1)
     self.assertEqual(msg_debug[3:6], [name,'DEBUG','debug'])
예제 #12
0
 def test_screen_filter(self):
     # make sure logging to screen works
     name = 'screen.filter'
     log = mlogging.config(name=name,
                           outputs=['screen'],
                           levels=['warning', 'debug'])
     # redirect stream to string io to capture
     log.handlers[0].stream = StringIO()
     log.critical('critical')
     log.error('error')
     log.warning('warning')
     log.info('info')
     log.debug('debug')
     log_output = log.handlers[0].stream.getvalue()
     msg_warning = get_linestring_split(log_output, 0)
     self.assertEqual(msg_warning[3:6], [name, 'WARNING', 'warning'])
     msg_debug = get_linestring_split(log_output, 1)
     self.assertEqual(msg_debug[3:6], [name, 'DEBUG', 'debug'])
예제 #13
0
파일: test.py 프로젝트: A32/pycodemo
 def test_remote_basic(self):
     # logging to remote scribe test
     name = 'remote.basic'
     log = mlogging.config(name=name, outputs=['remote'])
     log.warning('warning')
예제 #14
0
 def test_remote_basic(self):
     # logging to remote scribe test
     name = 'remote.basic'
     log = mlogging.config(name=name, outputs=['remote'])
     log.warning('warning')