* [PATCH] oeqa/utils/httpserver: connect up the request logging
@ 2023-01-26 17:30 Ross Burton
2023-01-27 17:20 ` [OE-core] " Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Ross Burton @ 2023-01-26 17:30 UTC (permalink / raw)
To: openembedded-core; +Cc: nd
Call logger.info() in the log_message handler so that we get request
logging, and hopefully even error messages.
Create a child logger to be neat and compartmentalise the logging.
Add a __main__ entrypoint so this class can be exercised outside of oeqa.
Remove unused traceback import.
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
meta/lib/oeqa/utils/httpserver.py | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/meta/lib/oeqa/utils/httpserver.py b/meta/lib/oeqa/utils/httpserver.py
index 8ce1dd42f49..b478172ed76 100644
--- a/meta/lib/oeqa/utils/httpserver.py
+++ b/meta/lib/oeqa/utils/httpserver.py
@@ -7,7 +7,6 @@
import http.server
import multiprocessing
import os
-import traceback
import signal
from socketserver import ThreadingMixIn
@@ -15,20 +14,21 @@ class HTTPServer(ThreadingMixIn, http.server.HTTPServer):
def server_start(self, root_dir, logger):
os.chdir(root_dir)
+ self.logger = logger
self.serve_forever()
class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def log_message(self, format_str, *args):
- pass
+ self.server.logger.info(format_str, *args)
-class HTTPService(object):
+class HTTPService:
def __init__(self, root_dir, host='', port=0, logger=None):
self.root_dir = root_dir
self.host = host
self.port = port
- self.logger = logger
+ self.logger = logger.getChild("HTTPService")
def start(self):
if not os.path.exists(self.root_dir):
@@ -49,7 +49,7 @@ class HTTPService(object):
signal.signal(signal.SIGTERM, orig)
if self.logger:
- self.logger.info("Started HTTPService on %s:%s" % (self.host, self.port))
+ self.logger.info("Started HTTPService for %s on %s:%s" % (self.root_dir, self.host, self.port))
def stop(self):
@@ -61,3 +61,10 @@ class HTTPService(object):
if self.logger:
self.logger.info("Stopped HTTPService on %s:%s" % (self.host, self.port))
+if __name__ == "__main__":
+ import sys, logging
+
+ logger = logging.getLogger(__name__)
+ logging.basicConfig(level=logging.DEBUG)
+ httpd = HTTPService(sys.argv[1], port=8888, logger=logger)
+ httpd.start()
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [OE-core] [PATCH] oeqa/utils/httpserver: connect up the request logging
2023-01-26 17:30 [PATCH] oeqa/utils/httpserver: connect up the request logging Ross Burton
@ 2023-01-27 17:20 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2023-01-27 17:20 UTC (permalink / raw)
To: Ross Burton; +Cc: openembedded-core, nd
Hello,
I believe this is the cause of:
https://autobuilder.yoctoproject.org/typhoon/#/builders/53/builds/6578/steps/16/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/42/builds/6555/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/60/builds/6539/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/63/builds/6529/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/59/builds/6520/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/73/builds/6516/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/74/builds/6522/steps/15/logs/stdio
On 26/01/2023 17:30:48+0000, Ross Burton wrote:
> Call logger.info() in the log_message handler so that we get request
> logging, and hopefully even error messages.
>
> Create a child logger to be neat and compartmentalise the logging.
>
> Add a __main__ entrypoint so this class can be exercised outside of oeqa.
>
> Remove unused traceback import.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
> meta/lib/oeqa/utils/httpserver.py | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/meta/lib/oeqa/utils/httpserver.py b/meta/lib/oeqa/utils/httpserver.py
> index 8ce1dd42f49..b478172ed76 100644
> --- a/meta/lib/oeqa/utils/httpserver.py
> +++ b/meta/lib/oeqa/utils/httpserver.py
> @@ -7,7 +7,6 @@
> import http.server
> import multiprocessing
> import os
> -import traceback
> import signal
> from socketserver import ThreadingMixIn
>
> @@ -15,20 +14,21 @@ class HTTPServer(ThreadingMixIn, http.server.HTTPServer):
>
> def server_start(self, root_dir, logger):
> os.chdir(root_dir)
> + self.logger = logger
> self.serve_forever()
>
> class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
>
> def log_message(self, format_str, *args):
> - pass
> + self.server.logger.info(format_str, *args)
>
> -class HTTPService(object):
> +class HTTPService:
>
> def __init__(self, root_dir, host='', port=0, logger=None):
> self.root_dir = root_dir
> self.host = host
> self.port = port
> - self.logger = logger
> + self.logger = logger.getChild("HTTPService")
>
> def start(self):
> if not os.path.exists(self.root_dir):
> @@ -49,7 +49,7 @@ class HTTPService(object):
> signal.signal(signal.SIGTERM, orig)
>
> if self.logger:
> - self.logger.info("Started HTTPService on %s:%s" % (self.host, self.port))
> + self.logger.info("Started HTTPService for %s on %s:%s" % (self.root_dir, self.host, self.port))
>
>
> def stop(self):
> @@ -61,3 +61,10 @@ class HTTPService(object):
> if self.logger:
> self.logger.info("Stopped HTTPService on %s:%s" % (self.host, self.port))
>
> +if __name__ == "__main__":
> + import sys, logging
> +
> + logger = logging.getLogger(__name__)
> + logging.basicConfig(level=logging.DEBUG)
> + httpd = HTTPService(sys.argv[1], port=8888, logger=logger)
> + httpd.start()
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#176413): https://lists.openembedded.org/g/openembedded-core/message/176413
> Mute This Topic: https://lists.openembedded.org/mt/96548159/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-27 17:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-26 17:30 [PATCH] oeqa/utils/httpserver: connect up the request logging Ross Burton
2023-01-27 17:20 ` [OE-core] " Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox