File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,31 @@ struct FileLogger <: AbstractLogger
3
3
always_flush:: Bool
4
4
end
5
5
6
+ """
7
+ FileLogger(path::AbstractString; append=false, always_flush=true)
8
+
9
+ Create a logger sink that write messages to a file specified with `path`.
10
+ To append to the file (rather than truncating the file first), use `append=true`.
11
+ If `always_flush=true` the stream is flushed after every handled log message.
12
+ """
6
13
function FileLogger (path; append= false , kwargs... )
7
14
filehandle = open (path, append ? " a" : " w" )
8
15
FileLogger (filehandle; kwargs... )
9
16
end
10
17
18
+ """
19
+ FileLogger(io::IOStream; always_flush=true)
20
+
21
+ Create a logger sink that write messages to the `io::IOStream`. The stream
22
+ is expected to be open and writeable.
23
+ If `always_flush=true` the stream is flushed after every handled log message.
24
+
25
+ # Examples
26
+ ```julia
27
+ io = open("path/to/file.log", "a") # append to the file
28
+ logger = FileLogger(io)
29
+ ```
30
+ """
11
31
function FileLogger (filehandle:: IOStream ; always_flush= true )
12
32
FileLogger (SimpleLogger (filehandle, BelowMinLevel), always_flush)
13
33
end
You can’t perform that action at this time.
0 commit comments