Skip to content

Commit 488eb1e

Browse files
committed
Some docstrings for FileLogger.
1 parent d680894 commit 488eb1e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/filelogger.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,31 @@ struct FileLogger <: AbstractLogger
33
always_flush::Bool
44
end
55

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+
"""
613
function FileLogger(path; append=false, kwargs...)
714
filehandle = open(path, append ? "a" : "w")
815
FileLogger(filehandle; kwargs...)
916
end
1017

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+
"""
1131
function FileLogger(filehandle::IOStream; always_flush=true)
1232
FileLogger(SimpleLogger(filehandle, BelowMinLevel), always_flush)
1333
end

0 commit comments

Comments
 (0)