Exemplo n.º 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'])
Exemplo n.º 2
0
Arquivo: test.py Projeto: 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'])
Exemplo n.º 3
0
Arquivo: test.py Projeto: 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'])
Exemplo n.º 4
0
Arquivo: test.py Projeto: 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'])
Exemplo n.º 5
0
Arquivo: test.py Projeto: 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'])
Exemplo n.º 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'])
Exemplo n.º 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'])
Exemplo n.º 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'])
Exemplo n.º 9
0
Arquivo: test.py Projeto: 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'])
Exemplo n.º 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'])
Exemplo n.º 11
0
Arquivo: test.py Projeto: 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'])
Exemplo n.º 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'])
Exemplo n.º 13
0
Arquivo: test.py Projeto: 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')
Exemplo n.º 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')