Logging error, close file

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)

I print the global_logger() in the file define the global logger and other files of the module. And found that the file logger only available in the file where define the module. In other files, it is the ConsoleLogger. This looks like the file logger only works in the file where it is defined.

I check the manual, which said

" the environment variable can be used to enable debug logging of modules, such as Pkg , or module roots (see Base.moduleroot ). To enable all debug logging, use the special value all ."

It said only affect the Debug log and still very confused.

The global logger in two files of the module is not same one as follows.

("SomeModule: ", global_logger()) = ("SomeModule: ", Base.CoreLogging.SimpleLogger(IOStream(<file /Users/zhangliye/julia_dev/mt/log2.txt>), Info, Dict{Any,Int64}()))

global_logger() = ConsoleLogger(Base.TTY(RawFD(0x00000016) open, 0 bytes waiting), Info, Logging.default_metafmt, true, 0, Dict{Any,Int64}())

The logger of python is very easy to use after reading the document. However, after reading the manual of Julia, still very confused. Any one can help? Thanks!