1 from __future__ import print_function
2 import sys
3 import os.path
4 import inspect
5
18
19
32
35 self.file = None
36 try:
37 name = os.path.abspath(name)
38 self.file = open(name,'a')
39 except:
40 try:
41 self.file = open('formatters.log','a')
42 except:
43 pass
44
50
54
59
60
61
62
63
64
66 - def __init__(self,autoflush=False,logcaller=False):
67 global _lldb_formatters_debug_level
68 global _lldb_formatters_debug_filename
69 self.autoflush = autoflush
70 want_log = False
71 try:
72 want_log = (_lldb_formatters_debug_level > 0)
73 except:
74 pass
75 if not (want_log):
76 self.impl = NopLogger()
77 return
78 want_file = False
79 try:
80 want_file = (_lldb_formatters_debug_filename != None and _lldb_formatters_debug_filename != '' and _lldb_formatters_debug_filename != 0)
81 except:
82 pass
83 if want_file:
84 self.impl = FileLogger(_lldb_formatters_debug_filename)
85 else:
86 self.impl = StdoutLogger()
87 try:
88 self.autoflush = (_lldb_formatters_debug_level > 1)
89 except:
90 self.autoflush = autoflush
91 want_caller_info = False
92 try:
93 want_caller_info = (_lldb_formatters_debug_level > 2)
94 except:
95 pass
96 if want_caller_info:
97 self._log_caller()
98
100 caller = inspect.stack()[2]
101 try:
102 if caller != None and len(caller) > 3:
103 self.write('Logging from function ' + str(caller))
104 else:
105 self.write('Caller info not available - Required caller logging not possible')
106 finally:
107 del caller
108
113
116
119
122