Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Ross Burton <ross.burton@arm.com>
Cc: openembedded-core@lists.openembedded.org, nd@arm.com
Subject: Re: [OE-core] [PATCH] oeqa/utils/httpserver: connect up the request logging
Date: Fri, 27 Jan 2023 18:20:51 +0100	[thread overview]
Message-ID: <Y9QH85/hCBXAVrMt@mail.local> (raw)
In-Reply-To: <20230126173048.1534444-1-ross.burton@arm.com>

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


      reply	other threads:[~2023-01-27 17:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 17:30 [PATCH] oeqa/utils/httpserver: connect up the request logging Ross Burton
2023-01-27 17:20 ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y9QH85/hCBXAVrMt@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=nd@arm.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=ross.burton@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox