-
Notifications
You must be signed in to change notification settings - Fork 24
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
ovirt-img: fix logging config #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍
9f16901
to
96abed4
Compare
This should theoretically fix the issue now but the logs get lost somewhere. They do not get printed through stdout, nor stderr. If I specify a file I can see the logs correctly in the file though. But I'm not sure where the logs are sent with default parameters. I'll continue investigating tomorrow. |
Seems to work ok for me:
Without debug log level it's hard to say, because nothing normally gets logged at warning level. |
--log-level=info works, your output shows INFO logs. |
This patch works on Fedora and CentOS Stream 8: diff --git a/ovirt_imageio/client/_options.py b/ovirt_imageio/client/_options.py
index 42a073c..048a486 100644
--- a/ovirt_imageio/client/_options.py
+++ b/ovirt_imageio/client/_options.py
@@ -117,8 +117,7 @@ class Parser:
name="log_file",
args=["--log-file"],
config=True,
- default="/dev/stderr",
- help="Log file name (default: /dev/stderr).",
+ help="Log to file instead of stderr.",
),
Option(
name="log_level", Example run:
|
If I run However, if redirected to a file, I can see many logs:
But is true that with a normal run, I get all logs printed to stderr as expected. I'll do a couple more tests and move on with this approach if I don't find any better option. |
96abed4
to
1d3fbb1
Compare
db4866f
to
d6da188
Compare
I reproduced the issue, this is not python 3.6 issue. Looks like debug logs from the sdk are missing when using --log-level debug and default log_level (None). It is my fault, this patch fixes the issue: diff --git a/ovirt_imageio/client/_options.py b/ovirt_imageio/client/_options.py
index 42a073c..048a486 100644
--- a/ovirt_imageio/client/_options.py
+++ b/ovirt_imageio/client/_options.py
@@ -117,8 +117,7 @@ class Parser:
name="log_file",
args=["--log-file"],
config=True,
- default="/dev/stderr",
- help="Log file name (default: /dev/stderr).",
+ help="Log to file instead of stderr.",
),
Option(
name="log_level",
diff --git a/ovirt_imageio/client/_ovirt.py b/ovirt_imageio/client/_ovirt.py
index f2ce99b..7b49f69 100644
--- a/ovirt_imageio/client/_ovirt.py
+++ b/ovirt_imageio/client/_ovirt.py
@@ -46,7 +46,7 @@ def connect(args):
username=args.username,
password=args.password,
ca_file=args.cafile,
- log=log if args.log_file else None,
+ log=log,
debug=args.log_level == "debug") But we also need to fix the tests assuming /dev/stderr. |
d6da188
to
79832f3
Compare
In ovit-img log_file defaults to /dev/stderr fd, and is passed to logging configurator through filename argument. However, this is not correct, filename only is used for files. File descriptions shall go as stream parameters. Otherwise the tool breaks with 'OSError: [Errno 29] Illegal seek' in an internal logging module. Reproduced with Python 3.6 in CentOS Stream 8. To solve it, default log_file to None instead, so that logging configuration does not use a filename and falls back to the stream argument, which defaults to stderr. Fixes: a2bbe12 Fixes: oVirt#113 Signed-off-by: Albert Esteve <aesteve@redhat.com>
79832f3
to
666bf82
Compare
Yes, sorry, I meant without specifying a log level at all. The default is warning, I thought, and there usually are no warnings, so I can't see if they would appear on the console. |
Interesting. I do, with the current version:
|
Current version is fixed. |
In ovit-img log_file defaults to /dev/stderr fd,
and is passed to logging configurator through
filename argument.
However, this is not correct, filename only is
used for files. File descriptions shall go
as stream parameters.
Otherwise the tool breaks with
'OSError: [Errno 29] Illegal seek'
in an internal logging module.
Reproduced with Python 3.6 in CentOS Stream 8.
To solve it, default log_file to None instead, so
that logging configuration does not use a filename
and falls back to the stream argument, which defaults
to stderr.
This PR implements part of #72.
Fixes: #113
Fixes: a2bbe12
Signed-off-by: Albert Esteve aesteve@redhat.com