-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My previous logging to file function will be affected by add pyxcp application .The previous log.info function reported errors #176
Comments
It‘s seems that : myself logger file handler was force closed when setup the pyxcy application. and the affected from class PyXCP(Application) which inherit from traitlet lib. But I can't locate the cause code in traitlet . |
Yes, pyXCP uses try:
# Offending code goes here.
except ValueError as e:
print(f"Logging error {e!r}") |
The effect of closing can be easily observed... python -c "import sys as s;s.stdout.close();print('hello')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: I/O operation on closed file. |
@christoph2 Can I disable pyxcp logger function? Now this feature applies to my use of other programs |
At the first sight, there are two places which could be commented out: pyxcp/pyxcp/config/__init__.py Line 941 in 0bcf714
pyxcp/pyxcp/config/__init__.py Line 956 in 0bcf714
If it helps, I'll add a configuration option. |
Also interesting would be something like logger = logging.getLogger("my-own-logger") as a starting point for your logging stuff. |
I've added a small test for a already configured root handler, if so use it. |
@christoph2 Thansk for your support ! I had try your method, It can solve the problem of error, but the function of affecting the file output to the file is no longer available. I use debug to locate the problem statement from this location. def read_configuration_file(self, file_name: str, emit_warning: bool = True):
self.legacy_config: bool = False this self.read_configuration_file(file_name,False) in _read_configuration(self, file_name: str, emit_warning: bool = True) -> None |
Fortunately, I solved the problem by adjusting the search. However, this logger is redirected to the root logger, I do not know if there will be other effects def start(self):
if self.subapp:
self.subapp.start()
exit(2)
else:
# self._setup_logger()
if logging.getLogger().hasHandlers():
self.log = logging.getLogger()
else:
self._setup_logger()
self._read_configuration(self.config_file) |
if logging.getLogger().hasHandlers():
self.log = logging.getLogger()
else:
self._setup_logger()
self._read_configuration(self.config_file) vs. self._read_configuration(self.config_file)
if logging.getLogger().hasHandlers():
self.log = logging.getLogger()
else:
self._setup_logger() Really makes a difference? The other thing that came to mind: I could add a |
Yea,It's make difference |
My previous logging to file function will be affected by add pyxcp application . The previous log.info function reported errors
only log to file is affected , the steram out is OK
File "C:\Users\XXXXXX\AppData\Local\anaconda3\Lib\logging_init_.py", line 1113, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
in my other coder logger config , I have code like this :
The text was updated successfully, but these errors were encountered: