File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
src/openlayer/lib/tracing Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -371,6 +371,23 @@ def sync_wrapper(*func_args, **func_kwargs):
371371 return decorator
372372
373373
374+ def log_output (output : Any ) -> None :
375+ """Logs output information to the current step of the trace.
376+
377+ This will overwrite the output of the currently active step instead of
378+ relying on the returned object from the traced function.
379+
380+ Args:
381+ output: The output value to log to the current step.
382+ """
383+ current_step = get_current_step ()
384+ if current_step :
385+ logger .debug ("Logging output to current step: %s" , output )
386+ current_step .log (output = output , metadata = {"manual_output_logged" : True })
387+ else :
388+ logger .warning ("No current step found to log output." )
389+
390+
374391def log_context (context : List [str ]) -> None :
375392 """Logs context information to the current step of the trace.
376393
@@ -562,9 +579,14 @@ def _finalize_step_logging(
562579 if step .latency is None :
563580 step .latency = (step .end_time - start_time ) * 1000 # in ms
564581
582+ # Check if manual output was logged
583+ if step .metadata .get ("manual_output_logged" ):
584+ logger .debug ("Using manually logged output for step: %s" , step .name )
585+ else :
586+ step .log (output = output )
587+
565588 step .log (
566589 inputs = inputs ,
567- output = output ,
568590 end_time = step .end_time ,
569591 latency = step .latency ,
570592 )
You can’t perform that action at this time.
0 commit comments