Exemple #1
0
 def test_basic(self):
     
     fmt = formats.LineFormat(separator='|', conversion=formats.line_conversion)
     
     opts = message.Message._default_options.copy()       
     msg = message.Message(levels.INFO, "I wear {0}", self.fields, opts, ['pants'], {})       
     assert fmt(msg) == '2010-10-28T02:15:57Z:INFO:mylog:pants=42|I wear pants\n'
Exemple #2
0
 def test_suppress_newline_false(self):
     
     fmt = formats.LineFormat(separator='|', conversion=formats.line_conversion)
     
     fields = self.fields.copy()
     fields['shirt'] = 'extra\nlarge'        
     
     opts = message.Message._default_options.copy()       
     opts['suppress_newlines'] = False
     msg = message.Message(levels.INFO, "I wear {0}\nDo you?", fields, opts, ['pants'], {})       
     s = fmt(msg)
     assert s == '2010-10-28T02:15:57Z:INFO:mylog:pants=42:shirt=extra\nlarge|I wear pants\nDo you?\n', repr(s)
Exemple #3
0
 def test_trace_fold(self):
     
     fmt = formats.LineFormat(separator='|', traceback_prefix = '\\n', conversion=formats.line_conversion)
     
     opts = message.Message._default_options.copy()       
     opts['trace'] = 'error'
     
     try:
         1/0
     except:
         msg = message.Message(levels.INFO, "I wear {0}", self.fields, opts, ['pants'], {})       
     
     s = fmt(msg)
     l = s.split('\n')
     assert len(l) == 2
Exemple #4
0
 def test_trace(self):
     
     fmt = formats.LineFormat(separator='|', conversion=formats.line_conversion)
     
     opts = message.Message._default_options.copy()       
     opts['trace'] = 'error'
     
     try:
         1/0
     except:
         msg = message.Message(levels.INFO, "I wear {0}", self.fields, opts, ['pants'], {})       
     
     s = fmt(msg)
     l = s.split('\n')
     assert len(l) == 6
     for i in l[1:-1]:
         assert i.startswith('TRACE')
         
     assert l[0] == '2010-10-28T02:15:57Z:INFO:mylog:pants=42|I wear pants'