@@ -48,7 +48,11 @@ def processor(source_code, filename, module):
4848 globals_processing (tree , module )
4949
5050
51- def compile_to_ir (filename : str , output : str ):
51+ def compile_to_ir (filename : str , output : str , loglevel = logging .WARNING ):
52+ logging .basicConfig (
53+ level = loglevel ,
54+ format = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
55+ )
5256 with open (filename ) as f :
5357 source = f .read ()
5458
@@ -134,7 +138,7 @@ def compile_to_ir(filename: str, output: str):
134138 return output
135139
136140
137- def compile () -> bool :
141+ def compile (loglevel = logging . WARNING ) -> bool :
138142 # Look one level up the stack to the caller of this function
139143 caller_frame = inspect .stack ()[1 ]
140144 caller_file = Path (caller_frame .filename ).resolve ()
@@ -143,7 +147,7 @@ def compile() -> bool:
143147 o_file = caller_file .with_suffix (".o" )
144148
145149 success = True
146- success = compile_to_ir (str (caller_file ), str (ll_file )) and success
150+ success = compile_to_ir (str (caller_file ), str (ll_file ), loglevel = loglevel ) and success
147151
148152 success = bool (
149153 subprocess .run (
@@ -165,7 +169,7 @@ def compile() -> bool:
165169 return success
166170
167171
168- def BPF () -> BpfProgram :
172+ def BPF (loglevel = logging . WARNING ) -> BpfProgram :
169173 caller_frame = inspect .stack ()[1 ]
170174 src = inspect .getsource (caller_frame .frame )
171175 with tempfile .NamedTemporaryFile (
@@ -178,7 +182,7 @@ def BPF() -> BpfProgram:
178182 f .write (src )
179183 f .flush ()
180184 source = f .name
181- compile_to_ir (source , str (inter .name ))
185+ compile_to_ir (source , str (inter .name ), loglevel = loglevel )
182186 subprocess .run (
183187 [
184188 "llc" ,
0 commit comments