Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.find fails when format doesn't include Log Level #13

Open
PFython opened this issue Dec 14, 2022 · 1 comment
Open

.find fails when format doesn't include Log Level #13

PFython opened this issue Dec 14, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@PFython
Copy link
Owner

PFython commented Dec 14, 2022

Here's the test I added to test_log2d.py which currently fails:

def test_find_without_loglevel():
    """ fmt may not include loglevel e.g. ERROR.  Test that .find still works"""
    fmt = Log.presets['name_and_time']
    mylog = Log("mylog", to_file=True, mode="w", to_stdout=True, fmt=fmt)
    mylog("This format has no log level")
    assert len(mylog.find()) == 1
    cleanup()

I think your approach for .find is based on the Log Level as separator. Sadly this isn't going to work for all formats. Maybe another approach is based on either or both of:

a) Passing the separator explicitly as an argument e.g. mylog.find(text="search for this", separator="|")
b) We know what mylog.fmt is... perhaps we can derive the logic from this, at least for the 5 or so preset formats?
c) Use a handful of regexes e.g. one to find a datetime element (if any), one to find loglevel, one to find log name? Then compare to see if they all start/end with the same character e.g. "|" which is likely to be the separator?

@PFython PFython added the bug Something isn't working label Dec 14, 2022
@MikeDP
Copy link
Contributor

MikeDP commented Mar 28, 2023

Fixed in pull request #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants