Skip to content

Commit 704110d

Browse files
authored
Removed import break (#937)
* breaking import * upgrade
1 parent db088a0 commit 704110d

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

agentops/logging/instrument_logging.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@
22
import logging
33
import os
44
import atexit
5-
from datetime import datetime
6-
from typing import Any, TextIO
7-
from agents import Span
5+
from typing import Any
86

97
_original_print = builtins.print
108

119
LOGFILE_NAME = "agentops-tmp.log"
1210

13-
## Instrument loggers and print function to log to a file
11+
# Instrument loggers and print function to log to a file
12+
13+
1414
def setup_print_logger() -> None:
1515
"""
1616
~Monkeypatches~ *Instruments the built-in print function and configures logging to also log to a file.
1717
Preserves existing logging configuration and console output behavior.
1818
"""
1919
log_file = os.path.join(os.getcwd(), LOGFILE_NAME)
20-
20+
2121
file_logger = logging.getLogger('agentops_file_logger')
2222
file_logger.setLevel(logging.DEBUG)
23-
23+
2424
file_handler = logging.FileHandler(log_file)
2525
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
2626
file_handler.setLevel(logging.DEBUG)
2727
file_logger.addHandler(file_handler)
28-
28+
2929
# Ensure the new logger doesn't propagate to root
3030
file_logger.propagate = False
31-
31+
3232
def print_logger(*args: Any, **kwargs: Any) -> None:
3333
"""
3434
Custom print function that logs to file and console.
35-
35+
3636
Args:
3737
*args: Arguments to print
3838
**kwargs: Keyword arguments to print
3939
"""
4040
message = " ".join(str(arg) for arg in args)
4141
file_logger.info(message)
42-
42+
4343
# print to console using original print
4444
_original_print(*args, **kwargs)
45-
45+
4646
# replace the built-in print with ours
4747
builtins.print = print_logger
4848

@@ -56,15 +56,15 @@ def cleanup():
5656
for handler in file_logger.handlers[:]:
5757
handler.close()
5858
file_logger.removeHandler(handler)
59-
59+
6060
# Restore the original print function
6161
builtins.print = _original_print
6262
except Exception as e:
6363
# If something goes wrong during cleanup, just print the error
6464
_original_print(f"Error during cleanup: {e}")
6565

6666
# Register the cleanup function to run when the process exits
67-
atexit.register(cleanup)
67+
atexit.register(cleanup)
6868

6969

7070
def upload_logfile(trace_id: int) -> None:
@@ -83,4 +83,3 @@ def upload_logfile(trace_id: int) -> None:
8383
client.api.v4.upload_logfile(log_content, trace_id)
8484

8585
os.remove(log_file)
86-

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "agentops"
7-
version = "0.4.7"
7+
version = "0.4.8"
88
authors = [
99
{ name="Alex Reibman", email="areibman@gmail.com" },
1010
{ name="Shawn Qiu", email="siyangqiu@gmail.com" },

0 commit comments

Comments
 (0)