I defined a file Logger in a Module and close the logger file in the test file. Error occurs as follows. Is this the proper way to use Logger in a user-defined module? Thanks!
module SomeModule
const g_pkg_dir = dirname(@__DIR__)
g_io_log = open( normpath(joinpath(g_pkg_dir, "../log.txt")), "w+" )
global_logger( SimpleLogger(g_io_log, Logging.Debug) )
function close_log()
flush(g_io_log)
close(g_io_log)
end
export close_log
end
## test_module.jl
import SomeModule
#SomeModule.do...
SomeModule.close_log() #error occurs here
Errors are as follows,
julia(19649,0x1094eae00) malloc: *** error for object 0x7f9949b81800: pointer being freed was not allocated
julia(19649,0x1094eae00) malloc: *** set a breakpoint in malloc_error_break to debug
signal (6): Abort trap: 6
in expression starting at /Users/zhangliye/julia_dev/mt/some_module/test/test_module.jl
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 98484280 (Pool: 98070713; Big: 413567); GC: 136
ERROR: Package SomeModule errored during testing (received signal: 6)