SegFault related to logging

Hi fellows,

I am having trouble with my own logger. I am using Julia’s logging system.

and the following write line gives me an error. However the println before it works just fine.

	    #IOBuffer
	    buf = IOBuffer()
	    iob = Indentable(IOContext(buf),indentlevel=logger[:indentlevel])
	    #iob = IOContext(buf, logger.stream)
	    levelstr = level == Warn ? "Warning" : string(level)
	    msglines = split(chomp(string(message)), '\n')
	    println(iob, "┌ ", levelstr, ": ", msglines[1])
	    
	    for i in 2:length(msglines)
	        println(iob,"│ ", msglines[i])
	    end
	    for (key, val) in kwargs
	        println(iob, "│   ", key, " = ", val)
	    end
	    println(iob, "└ @ ", something(_module, "nothing"), " ",
	            something(filepath, "nothing"), ":", something(line, "nothing"))
	    #println(String(take!(buf)))
	    **write(logger.stream,take!(buf))**

and the error is;

ignal (11): Segmentation fault: 11
in expression starting at no file:0
uv_write2 at /Users/osx/buildbot/slave/package_osx64/build/deps/srccache/libuv-ed3700c849289ed01fe04273a7bf865340b2bd7e/src/unix/stream.c:1432
uv_write at /Users/osx/buildbot/slave/package_osx64/build/deps/srccache/libuv-ed3700c849289ed01fe04273a7bf865340b2bd7e/src/unix/stream.c:1524
jl_uv_write at /Users/osx/buildbot/slave/package_osx64/build/src/jl_uv.c:454
uv_write_async at ./stream.jl:810
uv_write at ./stream.jl:778
flush at ./stream.jl:861
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1829

and the lldb says

Process 56036 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x000000010023c928 libjulia.dylib`uv_write2 + 104
libjulia.dylib`uv_write2:
->  0x10023c928 <+104>: cmpl   $0xc, 0x10(%rax)
    0x10023c92f <+111>: je     0x10023c95e               ; <+158>
    0x10023c935 <+117>: movq   -0x18(%rbp), %rax
    0x10023c939 <+121>: cmpl   $0x7, 0x10(%rax)
Target 0: (julia) stopped.