1  from __future__ import print_function 
  2  import sys 
  3  import os.path 
  4  import inspect 
  5   
  6   
 20   
 21   
 35   
 36   
 38   
 40          self.file = None 
 41          try: 
 42              name = os.path.abspath(name) 
 43              self.file = open(name, 'a') 
 44          except: 
 45              try: 
 46                  self.file = open('formatters.log', 'a') 
 47              except: 
 48                  pass 
  49   
 55   
 59   
  64   
 65   
 66   
 67   
 68   
 69   
 70   
 71   
 72   
 73   
 75   
 76 -    def __init__(self, autoflush=False, logcaller=False): 
  77          global _lldb_formatters_debug_level 
 78          global _lldb_formatters_debug_filename 
 79          self.autoflush = autoflush 
 80          want_log = False 
 81          try: 
 82              want_log = (_lldb_formatters_debug_level > 0) 
 83          except: 
 84              pass 
 85          if not (want_log): 
 86              self.impl = NopLogger() 
 87              return 
 88          want_file = False 
 89          try: 
 90              want_file = (_lldb_formatters_debug_filename is not None and _lldb_formatters_debug_filename != 
 91                           '' and _lldb_formatters_debug_filename != 0) 
 92          except: 
 93              pass 
 94          if want_file: 
 95              self.impl = FileLogger(_lldb_formatters_debug_filename) 
 96          else: 
 97              self.impl = StdoutLogger() 
 98          try: 
 99              self.autoflush = (_lldb_formatters_debug_level > 1) 
100          except: 
101              self.autoflush = autoflush 
102          want_caller_info = False 
103          try: 
104              want_caller_info = (_lldb_formatters_debug_level > 2) 
105          except: 
106              pass 
107          if want_caller_info: 
108              self._log_caller() 
 109   
111          caller = inspect.stack()[2] 
112          try: 
113              if caller is not None and len(caller) > 3: 
114                  self.write('Logging from function ' + str(caller)) 
115              else: 
116                  self.write( 
117                      'Caller info not available - Required caller logging not possible') 
118          finally: 
119              del caller   
 120   
125   
128   
131   
 134