Bug 4085

Summary: Not all WARNINGS are stored in qa.log
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Martin Jansa <Martin.Jansa>
Component: configurationAssignee: Joshua Watt <JPEWhacker>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Low CC: JPEWhacker, Qi.Chen, randy.macleod, richard.purdie, ross.burton, sangeeta.jain, sgw
Version: 1.4   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Martin Jansa 2013-03-22 10:17:53 UTC
It would be nice to store all WARNINGS shown while building in some file like qa.log (can be different file).

e.g. warning from sstate that some recipe is trying to overwrite something in sysroot is important enough (IIRC it's supposed to became fatal at some point) and still warning can be forgotten after build.

For my jenkins builds used as pre-commit check for meta-oe changes I'm archiving qa.log as one of build artifacts and one of merge criteria is not to introduce new QA warnings, it would be nice to extend this to all new warnings (without greping whole cooker log).
Comment 1 Chen Qi 2013-11-18 12:23:07 UTC
I think this is something we need to do now.

I think we might need to refactor the code a little bit. After all, not all WARNINGS are related to the packaging process and package_qa_handle_error thus not a suitable name for a generic function to handle all warnings.

I also suggest that we use buildhistory to manage that qa.log file.

//Chen Qi
Comment 2 Ross Burton 2015-11-10 17:13:34 UTC
Now that bbwarn routes the messages to bitbake (instead of just being a wrapper around echo) all the warnings from shell will be in the log.

Marking as NEEDINFO as I believe this is actually resolved now.  Martin, as you filed this, do you have any opinion?
Comment 3 Ross Burton 2015-11-10 17:14:33 UTC
.
Comment 4 Martin Jansa 2015-11-10 17:47:10 UTC
> Now that bbwarn routes the messages to bitbake (instead of just being a wrapper around echo) all the warnings from shell will be in the log.

That's definitely an improvement, but doesn't implement the description:

> It would be nice to store all WARNINGS shown while building in some file like qa.log (can be different file).

>  it would be nice to extend this to all new warnings (without greping whole cooker log).

Basically I need to check qa.log for QA issues.

_AND_ grep bitbake log for all other ERROR, WARNING (grep -v QA issues).

This ticket was about storing all warnings/errors in qa.log file or introducing new issues.log file which will contain only ERRORs and WARNINGs.
Comment 5 Ross Burton 2015-11-10 18:45:03 UTC
Is this just a convenience over filtering out NOTE/INFO from the cooker log?  Or is there something else I'm still missing?
Comment 6 Martin Jansa 2015-11-10 18:49:33 UTC
Yes convenience, like separate qa.log file is.
Comment 7 Ross Burton 2015-12-03 16:08:08 UTC
Right.  Sounds like a good argument to remove the special handling of qa.log and instead allowing bitbake to write more log files depending on the level.
Comment 8 Ross Burton 2015-12-03 16:34:13 UTC
This three-line patch to bitbake:

        handler = logging.FileHandler("/tmp/badlog")
        handler.setLevel(logging.WARNING)
        bb.logger.addHandler(handler)

Mostly does what you want.  Annoyingly doing this from a class is non-trivial as classes are invoked multiple times at startup so the log has duplicates in.
Comment 9 Sangeeta Jain 2021-01-26 08:18:15 UTC
Is it still an issue? someone working on it?
Comment 10 Richard Purdie 2023-01-26 16:09:07 UTC
I believe that we can now configure bitbake's logging from a configuration file so this can likely be done that way, we do something a bit like that on the autobuilder.

We can likely close this once we check such a config is possible. 

There is a separate bug for shsowing warnings for things restored from sstate.
Comment 11 Joshua Watt 2023-01-26 21:13:11 UTC
This can be acomplished today with a log config file. Set BB_LOGCONFIG to point to a json file that contains:

{
    "version": 1,
    "formatters": {
        "warnlogFormatter": {
            "()": "bb.msg.BBLogFormatter",
            "format": "%(levelname)s: %(message)s"
        }
    },
    "handlers": {
        "warnlog": {
            "class": "logging.FileHandler",
            "formatter": "warnlogFormatter",
            "level": "WARNING",
            "filename": "warn.log"
        }
    },
    "loggers": {
        "BitBake": {
            "handlers": ["warnlog"]
        }
    },
    "@disable_existing_loggers": false
}

And all WARNINGS and higher will be sent to "warn.log"
Comment 12 Martin Jansa 2023-01-26 21:51:55 UTC
Thanks, it might take a while to update various jenkins jobs etc to use this, but I agree that this is reasonable long term solution better than special handling of qa.log.