Merge lp:~elopio/snapcraft/fix1476452-python_log into lp:~snappy-dev/snapcraft/core
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Michael Terry on 2015-07-29 | ||||
| Approved revision: | 112 | ||||
| Merged at revision: | 110 | ||||
| Proposed branch: | lp:~elopio/snapcraft/fix1476452-python_log | ||||
| Merge into: | lp:~snappy-dev/snapcraft/core | ||||
| Prerequisite: | lp:~elopio/snapcraft/test_tmp_cwd | ||||
| Diff against target: |
669 lines (+176/-69) 14 files modified
integration-tests/units/jobs.pxu (+4/-4) snapcraft/__init__.py (+14/-5) snapcraft/cmds.py (+9/-5) snapcraft/common.py (+0/-5) snapcraft/main.py (+8/-0) snapcraft/plugin.py (+8/-4) snapcraft/plugins/ant_project.py (+7/-2) snapcraft/plugins/copy.py (+5/-1) snapcraft/plugins/ubuntu.py (+10/-4) snapcraft/tests/test_cmds.py (+45/-8) snapcraft/tests/test_copy_plugin.py (+15/-8) snapcraft/tests/test_plugin.py (+17/-4) snapcraft/tests/test_yaml.py (+23/-14) snapcraft/yaml.py (+11/-5) |
||||
| To merge this branch: | bzr merge lp:~elopio/snapcraft/fix1476452-python_log | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Terry (community) | Approve on 2015-07-29 | ||
| Michael Vogt | 2015-07-21 | Approve on 2015-07-22 | |
|
Review via email:
|
|||
Commit Message
Use the python logger.
Description of the Change
The python logger is nice. I've just done the basic config to keep the previous behaviour, but there are many options. At some point we should add an extra handler to send the logs to a file.
By using this logger, now it becomes testable too. I've added some tests, but to add the rest I need to learn a little more about snapcraft.
| Michael Terry (mterry) wrote : | # |
A) This has conflicts now
B) Does this keep the bold text output? I thought that was rather valuable for separating the non-bold output of plugin subprocesses from the bold output of snapcraft itself (bracketing plugin output when going through the stages).
I'd prefer to keep that if possible.
| Leo Arias (elopio) wrote : | # |
> A) This has conflicts now
and it requires sergio to add fixtures to the machine :(
> B) Does this keep the bold text output? I thought that was rather valuable
> for separating the non-bold output of plugin subprocesses from the bold output
> of snapcraft itself (bracketing plugin output when going through the stages).
>
> I'd prefer to keep that if possible.
No, it doesn't. I can do it with with separate handlers and filters, I think. Let me try.
| Leo Arias (elopio) wrote : | # |
> Thanks for this branch. I like it and code-wise it looks great, just two
> comments inline (which are the same) where a small comment might be helpful. I
> +1 on this branch but I will leave the top-approve to Mike.
Thanks for the review. I added comments on all the checks for the return code.
| Leo Arias (elopio) wrote : | # |
> A) This has conflicts now
Merged and all tests passing.
> B) Does this keep the bold text output? I thought that was rather valuable
> for separating the non-bold output of plugin subprocesses from the bold output
> of snapcraft itself (bracketing plugin output when going through the stages).
>
> I'd prefer to keep that if possible.
Now the logger format has the bold wrapper. Please check if that's what you wanted.
| Michael Terry (mterry) wrote : | # |
From IRC:
<mterry> elopio, looking at your branch -- now some things are bold that weren't before
<mterry> elopio, look at the diff in LP and you can see some things were just print() lines before
elopio, specifically when we ran a subcommand, it would not be bold
elopio, and a couple tiny other places
elopio, what's the cleanest way to distinguish there? Use another logger command than info?
| Leo Arias (elopio) wrote : | # |
> From IRC:
>
>
> <mterry> elopio, looking at your branch -- now some things are bold that
> weren't before
> <mterry> elopio, look at the diff in LP and you can see some things were just
> print() lines before
> elopio, specifically when we ran a subcommand, it would not be bold
> elopio, and a couple tiny other places
> elopio, what's the cleanest way to distinguish there? Use another logger
> command than info?l
No, I think the correct way is to define a different logger, like:
subcommand_logger = logging.
And then we add a handler to that subcommand_logger that has a formatter without the bold wrapper.
However, if you see at the statements that use print:
66 - print(' '.join(cmd))
141 - snapcraft.
142 - print()
143 - print(yaml)
170 - print("Installing required packages on the host system: " + ", ".join(
I fail to see a pattern in there that we can generalize in a logger. So maybe instead, each call to the logger should decide if it should be wrapped in bold or not. And IMO, instead of using \bold it would be clearer to use the name of the package. Like:
snapcraft log message-1
plugin.ubuntu: ubuntu log message-1
...
plugin.ubuntu: ubuntu log message-n
snapcraft log message-last
In the end, I think we should define a logging policy so we can be consistent on how to use it, and then define the logger hierarchy so it's easy to use. For now, I'll revert those lines to use print so this branch will introduce the loggers while keeping the exact same behaviour as before. And lets start the discussion.
| Michael Terry (mterry) wrote : | # |
Looks good. We can go over the bold/not-bold stuff separately. I'm sure there's a nicer way to distinguish those.


Thanks for this branch. I like it and code-wise it looks great, just two comments inline (which are the same) where a small comment might be helpful. I +1 on this branch but I will leave the top-approve to Mike.