Without the %d present in the log message string, the call to logger.info() as always throwing a TypeError upon running the server.
I created a short script, logging_bug.py for testing:
import logging
from scienceworld import ScienceWorldEnv
logging.basicConfig(level=logging.INFO)
ScienceWorldEnv()
Here is the output before and after my fix:
$ python logging_bug.py
INFO:py4j.java_gateway:Callback Server Starting
INFO:py4j.java_gateway:Socket listening on ('127.0.0.1', 62918)
--- Logging error ---
Traceback (most recent call last):
File "/Users/ahedges/.pyenv/versions/3.8.15/lib/python3.8/logging/__init__.py", line 1085, in emit
msg = self.format(record)
File "/Users/ahedges/.pyenv/versions/3.8.15/lib/python3.8/logging/__init__.py", line 929, in format
return fmt.format(record)
File "/Users/ahedges/.pyenv/versions/3.8.15/lib/python3.8/logging/__init__.py", line 668, in format
record.message = record.getMessage()
File "/Users/ahedges/.pyenv/versions/3.8.15/lib/python3.8/logging/__init__.py", line 373, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "logging_bug.py", line 4, in <module>
ScienceWorldEnv()
File "/Users/ahedges/projects/personal/ScienceWorld/scienceworld/scienceworld.py", line 51, in __init__
logger.info("ScienceWorld server running on port", port)
Message: 'ScienceWorld server running on port'
Arguments: (62917,)
$ python logging_bug.py
INFO:py4j.java_gateway:Callback Server Starting
INFO:py4j.java_gateway:Socket listening on ('127.0.0.1', 62936)
INFO:scienceworld.scienceworld:ScienceWorld server running on port 62935
I also made two other small changes while I was at it.
Without the
%d
present in the log message string, the call tologger.info()
as always throwing aTypeError
upon running the server.I created a short script,
logging_bug.py
for testing:Here is the output before and after my fix:
I also made two other small changes while I was at it.