From 50e3eb2a087d23c25adebc723539d3f88fe91ccc Mon Sep 17 00:00:00 2001 From: Chris Foster Date: Tue, 2 Jul 2019 17:00:32 +1000 Subject: [PATCH] Fix tab completion in Logging for functions from CoreLogging CoreLogging is an implementation detail, but the fact that Logging imports things from there breaks tab completion for the parts of the public API which aren't re-exported. Fix this by explicitly creating bindings for each imported symbol. --- stdlib/Logging/src/Logging.jl | 41 ++++++++++++++++----------------- stdlib/Logging/test/runtests.jl | 7 ++++++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/stdlib/Logging/src/Logging.jl b/stdlib/Logging/src/Logging.jl index 3869190f2867d..b44b8ae67473c 100644 --- a/stdlib/Logging/src/Logging.jl +++ b/stdlib/Logging/src/Logging.jl @@ -8,27 +8,26 @@ and available by default. """ module Logging -# For now, simply import most names from Base - we don't want to fully -# stabilize this API for 1.0 so it should officially live here in a stdlib -# package. -# -# See #24490 - -import Base.CoreLogging: - LogLevel, BelowMinLevel, Debug, Info, Warn, Error, AboveMaxLevel, - AbstractLogger, - NullLogger, - handle_message, shouldlog, min_enabled_level, catch_exceptions, - @debug, - @info, - @warn, - @error, - @logmsg, - with_logger, - current_logger, - global_logger, - disable_logging, - SimpleLogger +# Import the CoreLogging implementation into Logging as new const bindings. +# Doing it this way (rather than with import) makes these symbols accessible to +# tab completion. +for sym in [ + :LogLevel, :BelowMinLevel, :Debug, :Info, :Warn, :Error, :AboveMaxLevel, + :AbstractLogger, + :NullLogger, + :handle_message, :shouldlog, :min_enabled_level, :catch_exceptions, + Symbol("@debug"), + Symbol("@info"), + Symbol("@warn"), + Symbol("@error"), + Symbol("@logmsg"), + :with_logger, + :current_logger, + :global_logger, + :disable_logging, + :SimpleLogger] + @eval const $sym = Base.CoreLogging.$sym +end export AbstractLogger, diff --git a/stdlib/Logging/test/runtests.jl b/stdlib/Logging/test/runtests.jl index 38c85b6d125f8..20ab421186fc8 100644 --- a/stdlib/Logging/test/runtests.jl +++ b/stdlib/Logging/test/runtests.jl @@ -8,6 +8,13 @@ import Logging: min_enabled_level, shouldlog, handle_message @testset "Logging" begin +@testset "Core" begin + # Symbols imported from CoreLogging should appear in tab completions + @test :AbstractLogger in names(Logging, all=true) # exported public type + @test :Info in names(Logging, all=true) # non-exported public constant + @test :handle_message in names(Logging, all=true) # non-exported public function +end + @testset "ConsoleLogger" begin # First pass log limiting @test min_enabled_level(ConsoleLogger(devnull, Logging.Debug)) == Logging.Debug