public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [oe-core][PATCH 1/1] runqemu: add some logging control
@ 2023-08-02 23:36 joe.slater
  2023-08-03  0:45 ` Randy MacLeod
  0 siblings, 1 reply; 2+ messages in thread
From: joe.slater @ 2023-08-02 23:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: joe.slater, randy.macleod

From: Joe Slater <joe.slater@windriver.com>

Use QB_LOG_FILE to log to a file, and QB_LOG_LEVEL
to set the base log level.  Example values -

QB_LOG_FILE="runq.log"
QB_LOG_LEVEL=DEBUG

Signed-off-by: Joe Slater <joe.slater@windriver.com>
---
 scripts/runqemu | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index 5e6793d44e..bea164d041 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -36,12 +36,20 @@ runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`\n\n %s" % message)
 
 def create_logger():
     logger = logging.getLogger('runqemu')
-    logger.setLevel(logging.INFO)
+    try:
+        logger.setLevel(os.getenv("QB_LOG_LEVEL"))
+    except:
+        logger.setLevel(logging.INFO)
 
-    # create console handler and set level to debug
-    ch = logging.StreamHandler()
-    ch.setLevel(logging.DEBUG)
 
+    # create a handler and set level to debug
+    try:
+        ch = logging.FileHandler(os.getenv("QB_LOG_FILE"))
+    except:
+        ch = logging.StreamHandler()
+
+    ch.setLevel(logging.DEBUG)
+    
     # create formatter
     formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-03  0:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02 23:36 [oe-core][PATCH 1/1] runqemu: add some logging control joe.slater
2023-08-03  0:45 ` Randy MacLeod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox