Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat #59

Merged
merged 9 commits into from
Mar 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ elif [[ "$TEST_TYPE" == "userimage" ]]; then
sysimg_lib = joinpath(LIB_PATH, "julia", "sys.$(Libdl.dlext)")
userimg_o = "userimg.o"
userimg_lib = "userimg.$(Libdl.dlext)"
run(`$(Base.julia_cmd()) --output-o $userimg_o --sysimage $sysimg_lib --startup-file=no -e "using Memento; logger = get_logger(\"Test\")"`)
run(`$(Base.julia_cmd()) --output-o $userimg_o --sysimage $sysimg_lib --startup-file=no -e "using Memento; logger = getlogger(\"Test\")"`)
run(`cc -shared -o $userimg_lib $userimg_o -ljulia -L$LIB_PATH`)
'
fi
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
julia 0.6
Compat 0.37.0
Compat 0.54.0
Syslogs 0.0.1
JSON 0.16.1
Nullables 0.0.3
24 changes: 6 additions & 18 deletions src/Memento.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ __precompile__()

module Memento

using Base: StackTrace, StackFrame
using Compat
using Compat.UUIDs
using Compat.Dates

import Syslogs
import JSON
using Nullables

import Base: show, info, warn, error, log

Expand All @@ -15,24 +18,9 @@ export debug, notice, error, critical, alert, emergency,
getlevel, setlevel!, addlevel!, setrecord!,
getlogger, gethandlers, getfilters, format, emit,

Logger,Record, DefaultRecord, Formatter, Handler,
DefaultFormatter, DictFormatter, DefaultHandler, FileRoller,
Logger, Record, DefaultRecord, Formatter, Handler,
DefaultFormatter, DictFormatter, DefaultHandler, FileRoller

# Deprecated
Syslog,
JsonFormatter,
is_set,
is_root,
get_level,
set_level,
add_level,
set_record,
filters,
add_filter,
add_handler,
remove_handler,
get_logger,
get_handlers

const DEFAULT_LOG_LEVEL = "warn"

Expand All @@ -54,7 +42,7 @@ include("filters.jl")
include("formatters.jl")
include("handlers.jl")
include("loggers.jl")
include("deprecated.jl")
include("syslog.jl")
include("test.jl")

# Initializing at compile-time will work as long as the loggers which are added do not
Expand Down
72 changes: 0 additions & 72 deletions src/deprecated.jl

This file was deleted.

8 changes: 4 additions & 4 deletions src/handlers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function DefaultHandler(filename::AbstractString, fmt::F=DefaultFormatter(), opt
setup_opts(opts)
handler = DefaultHandler(fmt, file, opts, Memento.Filter[], Ref(_log_levels), "not_set")
push!(handler, Memento.Filter(handler))
finalizer(handler, h -> close(h.io))
@compat finalizer(h -> close(h.io), handler)
handler
end

Expand Down Expand Up @@ -158,10 +158,10 @@ function emit(handler::DefaultHandler{F, O}, rec::Record) where {F<:Formatter, O
str = format(handler.fmt, rec)

if handler.opts[:is_colorized] && haskey(handler.opts[:colors], level)
print_with_color(
handler.opts[:colors][level],
printstyled(
handler.io,
string(str,"\n")
string(str,"\n"),
color=handler.opts[:colors][level],
)
else
println(handler.io, str)
Expand Down
2 changes: 1 addition & 1 deletion src/loggers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Adds a new `Handler` to the logger.
"""
function Base.push!(logger::Logger, handler::Handler)
handler.levels.x = logger.levels
logger.handlers[string(Base.Random.uuid4())] = handler
logger.handlers[string(uuid4())] = handler
end

"""
Expand Down
2 changes: 1 addition & 1 deletion src/records.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function DefaultRecord(name::AbstractString, level::AbstractString, levelnum::In
Attribute(AbstractString, get_msg(msg)),
Attribute(name),
Attribute(myid()),
Attribute(Union{StackFrame, Void}, get_lookup(trace)),
Attribute(Union{StackFrame, Nothing}, get_lookup(trace)),
trace,
)
end
Expand Down
11 changes: 11 additions & 0 deletions src/syslog.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is necessary or Memento will attempt to use `println` with one argument (unsupported by Syslog)
# This should be handled by optional dependency stuff in the future
"""
emit{F, O}(handler::DefaultHandler{F, O}, rec::Record) where {F<:Formatter, O<:Syslog}

Handles printing any records with any `Formatter` and a `Syslog` `IO` type.
"""
function Memento.emit(handler::DefaultHandler{F, O}, rec::Record) where {F<:Formatter, O<:Syslogs.Syslog}
println(handler.io, rec[:level], format(handler.fmt, rec))
flush(handler.io)
end
5 changes: 3 additions & 2 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# PkgBenchmark 0.0.1
# BenchmarkTools 0.0.7
Syslogs 0.0.1
Syslogs 0.1.1
JSON 0.16.1
Suppressor 0.0.5
Suppressor 0.0.5
TestSetExtensions
180 changes: 0 additions & 180 deletions test/deprecated.jl

This file was deleted.

Loading