From: Joe Slater <[email protected]>

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 <[email protected]>
---
 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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#185444): 
https://lists.openembedded.org/g/openembedded-core/message/185444
Mute This Topic: https://lists.openembedded.org/mt/100516758/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to