Skip to content

Commit c74ee3a

Browse files
committed
Drop compat code for at-warn and friends from #458
And mark `enable_debug(::Bool)` for deprecation.
1 parent 4931db2 commit c74ee3a

File tree

3 files changed

+1
-76
lines changed

3 files changed

+1
-76
lines changed

README.md

-11
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,6 @@ Currently, the `@compat` macro supports the following syntaxes:
202202

203203
## New macros
204204

205-
* The logging macros `@error`, `@warn`, `@info` and `@debug` can be used as
206-
`Compat.@error`, `Compat.@warn`, `Compat.@info` and `Compat.@debug` on Julia 0.6 ([#24490]).
207-
Note that the behavior do not mirror the logging macros in Julia 0.7, instead on Julia 0.6:
208-
- Messages are printed to `STDERR` (like `info` and `warn` on Julia 0.6) and not to a
209-
dedicated logging stream.
210-
- The loglevel can not be controlled, but `Compat.@debug` messages can be turned on/off
211-
by calling `Compat.enable_debug(true/false)`.
212-
- Extra metadata sent to the macros are ignored.
213-
214-
As an alternative, see the MicroLogging.jl package for a logging interface similar to the one in Julia 0.7.
215-
216205
## Other changes
217206

218207
* On versions of Julia that do not contain a Base.Threads module, Compat defines a Threads module containing a no-op `@threads` macro.

src/Compat.jl

+1-41
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ end
4545
import Base: notnothing
4646
const IteratorSize = Base.IteratorSize
4747
const IteratorEltype = Base.IteratorEltype
48+
enable_debug(x::Bool) = x
4849

4950

5051
include("compatmacro.jl")
@@ -70,47 +71,6 @@ end
7071
end
7172
end
7273

73-
@static if !isdefined(Base, Symbol("@info"))
74-
macro info(msg, args...)
75-
return :(info($(esc(msg)), prefix = "Info: "))
76-
end
77-
end
78-
@static if !isdefined(Base, Symbol("@warn"))
79-
macro warn(msg, args...)
80-
return :(warn($(esc(msg)), prefix = "Warning: "))
81-
end
82-
end
83-
84-
const DEBUG = Ref(false) # debug printing off by default, as on 0.7
85-
enable_debug(x::Bool) = DEBUG[] = x
86-
@static if !isdefined(Base, Symbol("@debug"))
87-
function debug(msg)
88-
DEBUG[] || return
89-
buf = Base.IOBuffer()
90-
iob = Base.redirect(IOContext(buf, STDERR), Base.log_info_to, :debug)
91-
print_with_color(:blue, iob, "Debug: "; bold = true)
92-
Base.println_with_color(:blue, iob, chomp(string(msg)))
93-
print(STDERR, String(take!(buf)))
94-
return
95-
end
96-
macro debug(msg, args...)
97-
return :(debug($(esc(msg))))
98-
end
99-
end
100-
@static if !isdefined(Base, Symbol("@error"))
101-
function _error(msg)
102-
buf = Base.IOBuffer()
103-
iob = Base.redirect(IOContext(buf, STDERR), Base.log_error_to, :error)
104-
print_with_color(Base.error_color(), iob, "Error: "; bold = true)
105-
Base.println_with_color(Base.error_color(), iob, chomp(string(msg)))
106-
print(STDERR, String(take!(buf)))
107-
return
108-
end
109-
macro error(msg, args...)
110-
return :(_error($(esc(msg))))
111-
end
112-
end
113-
11474
# 0.7.0-DEV.3415
11575
if !isdefined(Base, :findall)
11676
const findall = find

test/runtests.jl

-24
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,6 @@ let A = [1]
8080
@test x == 1
8181
end
8282

83-
if !isdefined(Base, Symbol("@info"))
84-
let fname = tempname()
85-
try
86-
open(fname, "w") do fout
87-
redirect_stderr(fout) do
88-
Compat.@info "A"
89-
Compat.@warn "B"
90-
oldstate = Compat.DEBUG[]
91-
Compat.enable_debug(false)
92-
Compat.@debug "C"
93-
Compat.enable_debug(true)
94-
Compat.@debug "D"
95-
Compat.enable_debug(oldstate)
96-
Compat.@error "E"
97-
end
98-
end
99-
@test read(fname, String) == (Base.have_color ? "\e[1m\e[36mInfo: \e[39m\e[22m\e[36mA\n\e[39m\e[1m\e[33mWarning: \e[39m\e[22m\e[33mB\e[39m\n\e[1m\e[34mDebug: \e[39m\e[22m\e[34mD\n\e[39m\e[1m\e[91mError: \e[39m\e[22m\e[91mE\n\e[39m" :
100-
"Info: A\nWarning: B\nDebug: D\nError: E\n")
101-
finally
102-
rm(fname, force=true)
103-
end
104-
end
105-
end
106-
10783
# 0.7.0-DEV.3460
10884
@test parentmodule(Compat.Sys) == Compat
10985
@test parentmodule(sin) == Base

0 commit comments

Comments
 (0)