Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

How to show output logzero's log in pytest #256

Open
testmtbf10 opened this issue Dec 19, 2019 · 0 comments
Open

How to show output logzero's log in pytest #256

testmtbf10 opened this issue Dec 19, 2019 · 0 comments

Comments

@testmtbf10
Copy link

testmtbf10 commented Dec 19, 2019

  • logzero version: 1.5
  • Python version: 3.6.5
  • Operating System: win7

Description

I want to show log which generated by logzero into pytest's html report file.
But, only the log use logging have been showed.

What I Did

My log has two different formatter:

  1. default formatter : just use logging.info() directly
  2. add an extra parameter in formatter(which i use logzero)
class Device(object):
    def __init__(self,device):
        self.d=u2.connect(device)
        tformater=logzero.LogFormatter(fmt='%(asctime)s [%(deviceid)s]%(levelname)1.1s %(message)s (%(filename)s:%(lineno)s)',datefmt='%Y-%m-%d %H:%M:%S')
        tlog=logzero.setup_logger(level=logging.DEBUG,formatter=tformater)
        self.log=logging.LoggerAdapter(tlog, {"deviceid":device})

When I run pytest , two parts are all shows in console.
But, part 2 not show in pytest's report file

in pytest.ini file ,I only set log_cli=1

@testmtbf10 testmtbf10 changed the title How to show output logzero's log How to show output logzero's log in pytest Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant