8000 Fix messy log truncations by macifell · Pull Request #41 · pimoroni/phew · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix messy log truncations #41

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions phew/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def truncate(file, target_size):

# try to find a line break nearby to split first chunk on
break_position = max(
chunk.find (b"\n", -discard), # search forward
chunk.rfind(b"\n", -discard) # search backwards
chunk.find (b"\n", -discard), # search forward
chunk.rfind(b"\n", 0, -discard) # search backwards
)
if break_position != -1: # if we found a line break..
outfile.write(chunk[break_position + 1:])
Expand Down Expand Up @@ -108,4 +108,4 @@ def debug(*items):

def exception(*items):
if _logging_types & LOG_EXCEPTION:
log("exception", " ".join(map(str, items)))
log("exception", " ".join(map(str, items)))
0