Skip to content

Commit 6d7f641

Browse files
PhilipVincShashikant Kadam
authored andcommitted
Add show to TBLogger object (JuliaLogging#31)
Add pretty-printing to `TBLogger` object
1 parent c1dd363 commit 6d7f641

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/TBLogger.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,21 @@ function handle_message(lg::TBLogger, level, message, _module, group, id, file,
231231
iter = increment_step!(lg, i_step)
232232
write_event(lg.file, make_event(lg, summ, step=iter))
233233
end
234+
235+
######################### Methods for pretty printing ##########################
236+
Base.show(io::IO, tbl::TBLogger) = begin
237+
str = "TBLogger(\"$(tbl.logdir)\"), min_level=$(tbl.min_level), "*
238+
"purge_step=$(tbl.global_step))"
239+
Base.print(io, str)
240+
end
241+
242+
Base.show(io::IO, mime::MIME"text/plain", tbl::TBLogger) = begin
243+
str = """
244+
TBLogger:
245+
- Log level : $(tbl.min_level)
246+
- Current step : $(tbl.global_step)
247+
- Output : $(tbl.logdir)
248+
- open files : $(length(tbl.all_files))
249+
"""
250+
Base.print(io, str)
251+
end

0 commit comments

Comments
 (0)