Created
December 23, 2013 23:46
-
-
Save timuruski/8106740 to your computer and use it in GitHub Desktop.
Operates a bit like sed without having to rebuild a string from an array of lines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOG_PATTERN = /^(INFO|DEBUG)\t[-0-9]+ [:0-9]+\t/ | |
def filter_and_format(log, level) | |
log.each_line.with_object("") { |line, filtered| | |
next unless line.start_with?(level) | |
filtered << line.sub(LOG_PATTERN, '') | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Somewhat equivalent to: