Multiple changes:
- Flush logfile writes per line - Remove note re: nimble version - Start debugging kernel buffer fills -- checkpoint - Add compile-time info to the version output - Write debug info to stderr instead of stdout - Use a debug maildir destination while developing FossilOrigin-Name: 85d29852920e6ff8fa266a963fbea11379b0bec2ab4fccab348f9e51784c8d4a
This commit is contained in:
parent
5ba41755a3
commit
138bca5b41
5 changed files with 28 additions and 14 deletions
|
|
@ -58,13 +58,6 @@ You can check out the current development source with Fossil via its
|
||||||
|
|
||||||
Alternatively, you can download the latest version [directly](https://code.martini.nu/fossil/sieb/uv/release/sieb-latest.tar.gz).
|
Alternatively, you can download the latest version [directly](https://code.martini.nu/fossil/sieb/uv/release/sieb-latest.tar.gz).
|
||||||
|
|
||||||
|
|
||||||
**NOTE**: As of Nim v0.16.4, the Nimble package manager is still at v0.13.1.
|
|
||||||
Sieb requires >= v0.14 of Nimble, you may need to update it first via:
|
|
||||||
|
|
||||||
% nimble install nimble
|
|
||||||
|
|
||||||
|
|
||||||
With the [nim](https://nim-lang.org/) environment installed and the Sieb
|
With the [nim](https://nim-lang.org/) environment installed and the Sieb
|
||||||
repository cloned, simply type:
|
repository cloned, simply type:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,4 +67,5 @@ proc log*( msg: string ): void =
|
||||||
## Emit a line to the logfile.
|
## Emit a line to the logfile.
|
||||||
if logger.closed: return
|
if logger.closed: return
|
||||||
logger.fh.writeLine( msg )
|
logger.fh.writeLine( msg )
|
||||||
|
logger.fh.flushFile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,21 +179,31 @@ proc filter*( orig_msg: Message, cmd: seq[string] ): Message =
|
||||||
# Read from the original message, write to the filter
|
# Read from the original message, write to the filter
|
||||||
# process in chunks.
|
# process in chunks.
|
||||||
#
|
#
|
||||||
orig_msg.open
|
"*** STARTING PIPE TO PROCESS".debug
|
||||||
|
var t = 0
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME: I think I'm a victim of the kernel buffer filling up
|
||||||
|
# with large messages. There are numerous posts regarding this.
|
||||||
|
# Might need to go lower level than "streams" with the child process.
|
||||||
|
#
|
||||||
while not orig_msg.stream.atEnd:
|
while not orig_msg.stream.atEnd:
|
||||||
buf = orig_msg.stream.readStr( BUFSIZE )
|
buf = orig_msg.stream.readStr( BUFSIZE )
|
||||||
|
t = t + BUFSIZE
|
||||||
process.inputStream.write( buf )
|
process.inputStream.write( buf )
|
||||||
process.inputStream.flush
|
process.inputStream.flush
|
||||||
|
echo "wrote ", t
|
||||||
|
"*** DONE PIPING TO PROCESS".debug # FIXME: hangs on large messages
|
||||||
|
|
||||||
# Read from the filter process until EOF, send to the
|
# Read from the filter process until EOF, send to the
|
||||||
# new message in chunks.
|
# new message in chunks.
|
||||||
#
|
#
|
||||||
process.inputStream.close
|
process.inputStream.close
|
||||||
|
process.errorStream.close
|
||||||
let new_msg = newMessage( orig_msg.dir )
|
let new_msg = newMessage( orig_msg.dir )
|
||||||
while not process.outputStream.atEnd:
|
while not process.outputStream.atEnd:
|
||||||
buf = process.outputStream.readStr( BUFSIZE )
|
buf = process.outputStream.readStr( BUFSIZE )
|
||||||
new_msg.stream.write( buf )
|
new_msg.stream.write( buf )
|
||||||
new_msg.stream.flush
|
|
||||||
|
|
||||||
let exitcode = process.waitForExit
|
let exitcode = process.waitForExit
|
||||||
"Filter exited: $#".debug( exitcode )
|
"Filter exited: $#".debug( exitcode )
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,14 @@ import
|
||||||
logging
|
logging
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
# C O N S T A N T S
|
# C O N S T A N T S
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
||||||
const
|
const
|
||||||
|
PLATFORM = staticExec( "uname -mo" )
|
||||||
|
COMPILEDATE = staticExec( "date '+%F'" )
|
||||||
VERSION = "v0.1.0" ## The current Sieb version
|
VERSION = "v0.1.0" ## The current Sieb version
|
||||||
USAGE = """
|
USAGE = """
|
||||||
./sieb [-c] [-d] [-h] [-v]
|
./sieb [-c] [-d] [-h] [-v]
|
||||||
|
|
@ -153,11 +156,11 @@ proc deferral*( msg: string ) =
|
||||||
|
|
||||||
|
|
||||||
proc debug*( msg: string, args: varargs[string, `$`] ) =
|
proc debug*( msg: string, args: varargs[string, `$`] ) =
|
||||||
## Emit `msg` if debug mode is enabled, coercing arguments into a string for
|
## Emit `msg` to stderr if debug mode is enabled, coercing arguments
|
||||||
## formatting.
|
## into a string for formatting.
|
||||||
if opts.debug or not logger.closed:
|
if opts.debug or not logger.closed:
|
||||||
var str = msg % args
|
var str = msg % args
|
||||||
if opts.debug: echo str
|
if opts.debug: stderr.writeLine( str )
|
||||||
if not logger.closed: str.log
|
if not logger.closed: str.log
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -201,7 +204,7 @@ proc parseCmdline*() =
|
||||||
opts.logfile = val
|
opts.logfile = val
|
||||||
|
|
||||||
of "version", "v":
|
of "version", "v":
|
||||||
echo "Sieb " & VERSION
|
echo "Sieb " & VERSION & ", compiled for " & PLATFORM & " on " & COMPILEDATE
|
||||||
quit( 0 )
|
quit( 0 )
|
||||||
|
|
||||||
else: discard
|
else: discard
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,13 @@ import
|
||||||
lib/util
|
lib/util
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# C O N S T A N T S
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
const MAILDIR = if defined( debug ): "Maildir-Sieb-DEBUG" else: "Maildir"
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
# S E T U P
|
# S E T U P
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
@ -31,7 +38,7 @@ parseCmdline()
|
||||||
|
|
||||||
let
|
let
|
||||||
home = getHomeDir()
|
home = getHomeDir()
|
||||||
default = newMaildir( joinPath( home, "Maildir" ) )
|
default = newMaildir( joinPath( home, MAILDIR ) )
|
||||||
|
|
||||||
# Open the optional log file.
|
# Open the optional log file.
|
||||||
if opts.logfile != "": createLogger( default.path, opts.logfile )
|
if opts.logfile != "": createLogger( default.path, opts.logfile )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue