commit e958983e3e18584784d13de8d9c4577265840ee0 Author: Jonathan Bernard Date: Thu Jul 6 00:54:38 2017 -0500 Initial version: dump file contents or exec command. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9b6a06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +log_happy +nimcache/ diff --git a/log_happy.nim b/log_happy.nim new file mode 100644 index 0000000..ab2363f --- /dev/null +++ b/log_happy.nim @@ -0,0 +1,239 @@ +## Log Happy +## ========= +## +## Little tool to extract expected information from log streams. +import json, logging, ncurses, os, osproc, streams, strutils, threadpool +import nre except toSeq + +import private/ncurses_ext + +from posix import signal + +type + Expectation* = ref object + label: string + pattern: Regex + expected, found: bool + +let expPattern = re"^-([eE])([^;]+);(.+)$" + +var msgChannel: Channel[string] + +proc exitErr(msg: string): void = + stderr.writeLine "log_happy: " & msg + quit(QuitFailure) + +proc readStream(stream: Stream): void = + var line = TaintedString"" + try: + while stream.readLine(line): msgChannel.send(line) + except: discard "" + +when isMainModule: + var cmdProc: Process + try: + let usage = """ +Usage: + log_happy [options] + log_happy [options] + log_happy [options] -- + +Options: + + -e