Skip to content

Searching other log files should be a Class Function #12

Description

@PFython

FYI I've already changed the argument name from "logname" to "path" which is shorter and better reflects the pathlib.Path syntax elsewhere in log2d. Hope that's ok Mike?

Anyhow... this enhancement is to change the way you access other log files. Your original solution requires people to create an instance of the Log class first and give it a name. I think a better and conceptually better approach would be for people to type:

Log.find(path="another_log_file.log")

or in other words make it a Class method. This might be tricky to implement because we want a .find method for individual instances too - we might have to rename it e.g. Log.find_in("another_log_file.log") and be clever about reusing the core search logic between the class method and the instance method.

If you're not familiar with class versus instance methods I appreciate this isn't going to make much sense!

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

def test_find_path():
    create_dummy_log()
    result = Log.find(path="mylog.log", date=timestamp, deltadays=-3)
    assert len(result) == 6, f"FIND14: Anotherlog - Expected 6 lines found {len(result)}"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions