From bda47a9d609fe46ff3a6abee8b36a035086d0ddf Mon Sep 17 00:00:00 2001 From: Kevin Squire Date: Tue, 11 Oct 2016 21:30:20 -0700 Subject: [PATCH 1/6] Update travis, add AppVeyor testing * travis: test on v0.5 * AppVeyor: add appveyor.yml --- .travis.yml | 1 + appveyor.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml index ea33da7c..5d308e7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ os: - osx julia: - 0.4 + - 0.5 - nightly notifications: email: false diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..be940168 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,34 @@ +environment: + matrix: + - JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe" + - JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" + - JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe" + - JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe" + +branches: + only: + - master + - /release-.*/ + +notifications: + - provider: Email + on_build_success: false + on_build_failure: false + on_build_status_changed: false + +install: +# Download most recent Julia Windows binary + - ps: (new-object net.webclient).DownloadFile( + $("http://s3.amazonaws.com/"+$env:JULIAVERSION), + "C:\projects\julia-binary.exe") +# Run installer silently, output to C:\projects\julia + - C:\projects\julia-binary.exe /S /D=C:\projects\julia + +build_script: +# Need to convert from shallow to complete for Pkg.clone to work + - IF EXIST .git\shallow (git fetch --unshallow) + - C:\projects\julia\bin\julia -e "versioninfo(); + Pkg.clone(pwd(), \"Logging\"); Pkg.build(\"Logging\")" + +test_script: + - C:\projects\julia\bin\julia -e "Pkg.test(\"Logging\")" From 3ddfcaa600a9c989f50f3abbb11f14ad536fb7b7 Mon Sep 17 00:00:00 2001 From: Kevin Squire Date: Tue, 11 Oct 2016 21:17:09 -0700 Subject: [PATCH 2/6] Stop exporting the log function --- src/Logging.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Logging.jl b/src/Logging.jl index 67a44d8e..e2c24d95 100644 --- a/src/Logging.jl +++ b/src/Logging.jl @@ -4,8 +4,8 @@ module Logging import Base: show, info, warn -export debug, info, warn, err, critical, log, - @debug, @info, @warn, @err, @error, @critical, +export debug, info, warn, err, critical, + @debug, @info, @warn, @err, @error, @critical, @log, Logger, LogLevel, DEBUG, INFO, WARNING, ERROR, CRITICAL, OFF, LogFacility, From 05016d87bc5b6c181792f7431fae9cf16e17b75e Mon Sep 17 00:00:00 2001 From: Kevin Squire Date: Tue, 11 Oct 2016 21:45:22 -0700 Subject: [PATCH 3/6] Update badges in README --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 68f3ff53..145d5393 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ -[![Build Status](https://travis-ci.org/kmsquire/Logging.jl.svg?branch=master)](https://travis-ci.org/kmsquire/Logging.jl) -[![Logging](http://pkg.julialang.org/badges/Logging_0.4.svg)](http://pkg.julialang.org/?pkg=Logging) - - Logging.jl: Basic logging for Julia =================================== +[![PkgEval: Julia v0.4](http://pkg.julialang.org/badges/Logging_0.4.svg)](http://pkg.julialang.org/?pkg=Logging) +[![PkgEval: Julia v0.5](http://pkg.julialang.org/badges/Logging_0.5.svg)](http://pkg.julialang.org/?pkg=Logging) +[![PkgEval: Julia v0.6](http://pkg.julialang.org/badges/Logging_0.6.svg)](http://pkg.julialang.org/?pkg=Logging) + +[![TravisCI: Linux, OSX](https://travis-ci.org/kmsquire/Logging.jl.svg?branch=master)](https://travis-ci.org/kmsquire/Logging.jl) +[![AppVeyorCI: Windows](https://ci.appveyor.com/api/projects/status/7cj5kaj8gcxmltho?svg=true)](https://ci.appveyor.com/project/kmsquire/logging-jl) + This module provides basic logging facilities for Julia. It was inspired somewhat by logging in Python. Install with `Pkg.add("Logging")` at the Julia prompt. From b1492b8a2aa1ab7ac8c7a0e62ca111b0e8ccceb0 Mon Sep 17 00:00:00 2001 From: Ranjan Anantharaman Date: Tue, 18 Oct 2016 11:16:53 +0530 Subject: [PATCH 4/6] Fix depwarn in test (#52) * Fix `Symbol` depwarn in test * Use `Compat` for v0.4 compatibilty --- REQUIRE | 1 + test/macro_test.jl | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index d5d64671..4c31c176 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1 +1,2 @@ julia 0.4 +Compat 0.7.15 diff --git a/test/macro_test.jl b/test/macro_test.jl index f8f062fd..8827d825 100644 --- a/test/macro_test.jl +++ b/test/macro_test.jl @@ -1,9 +1,10 @@ using Logging using Base.Test +using Compat function test_log_macro_common(flags) for (macroname, isshown) in flags - ex = Expr(:macrocall, symbol(macroname), "test message") + ex = Expr(:macrocall, Symbol(macroname), "test message") if isshown @test ex |> macroexpand != :nothing else From b4809ec4d42ea4c9b58e0c9d10ae794b9f6bb9e9 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Thu, 4 May 2017 23:48:39 -0400 Subject: [PATCH 5/6] Attempt to fix Julia v0.6 support (#54) * fix keyword handling in julia v0.6 * use Compat: @static * macro hygiene fixes * ensure that macros work inside modules too --- .travis.yml | 1 + src/Logging.jl | 14 +++++++++-- src/logging_macros.jl | 4 ++-- test/macro_scope_test.jl | 51 ++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 1 + 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 test/macro_scope_test.jl diff --git a/.travis.yml b/.travis.yml index 5d308e7a..a2fe4ee2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ os: julia: - 0.4 - 0.5 + - 0.6 - nightly notifications: email: false diff --git a/src/Logging.jl b/src/Logging.jl index e2c24d95..5160375e 100644 --- a/src/Logging.jl +++ b/src/Logging.jl @@ -2,6 +2,7 @@ __precompile__() module Logging +using Compat: @static import Base: show, info, warn export debug, info, warn, err, critical, @@ -142,11 +143,20 @@ end override_info(;args...) = (:override_info, true) in args +# Keyword arguments x=1 passed to macros are parsed as Expr(:(=), :x, 1) but +# must be passed as Expr(:(kw), :x, 1) in Julia v0.6. +@static if VERSION < v"0.6-" + fix_kwarg(x) = x +else + fix_kwarg(x::Symbol) = x + fix_kwarg(e::Expr) = e.head == :(=) ? Expr(:(kw), e.args...) : e +end + macro configure(args...) _args = gensym() quote - logger = Logging.configure($(args...)) - if Logging.override_info($(args...)) + logger = Logging.configure($([fix_kwarg(a) for a in args]...)) + if Logging.override_info($([fix_kwarg(a) for a in args]...)) function Base.info(msg::AbstractString...) Logging.info(Logging._root, msg...) end diff --git a/src/logging_macros.jl b/src/logging_macros.jl index 52df3496..e3e070da 100644 --- a/src/logging_macros.jl +++ b/src/logging_macros.jl @@ -15,9 +15,9 @@ for (mac,fn,lvl) in ((:debug, :(Logging.debug), Logging.DEBUG), end if $lvl > level - :nothing + esc(:nothing) else - Expr(:call, $fn, msg...) + Expr(:call, $fn, [esc(m) for m in msg]...) end end diff --git a/test/macro_scope_test.jl b/test/macro_scope_test.jl new file mode 100644 index 00000000..a27d5281 --- /dev/null +++ b/test/macro_scope_test.jl @@ -0,0 +1,51 @@ +# Ensure that Logging.jl works when loaded with `import` rather than `using` +# since `import` does not bring constants like `DEBUG` into scope: +module InnerModule + +import Logging +@Logging.configure(level=DEBUG) + +using Compat +using Base.Test + +function test_non_global_interpolation(y) + @info("y = $y") +end + +test_non_global_interpolation(5) + +function test_log_macro_common(flags) + for (macroname, isshown) in flags + ex = Expr(:macrocall, Symbol(macroname), "test message") + if isshown + @test ex |> macroexpand != :nothing + else + @test ex |> macroexpand == :nothing + end + end +end + +test_log_macro_common([(:@debug, true), (:@info, true), (:@warn, true), + (:@err, true), (:@critical, true)]) + +@Logging.configure(level=INFO) +test_log_macro_common([(:@debug, false), (:@info, true), (:@warn, true), + (:@err, true), (:@critical, true)]) + +@Logging.configure(level=WARNING) +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, true), + (:@err, true), (:@critical, true)]) + +@Logging.configure(level=ERROR) +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, false), + (:@err, true), (:@critical, true)]) + +@Logging.configure(level=CRITICAL) +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, false), + (:@err, false), (:@critical, true)]) + +@Logging.configure(level=OFF) +test_log_macro_common([(:@debug, false), (:@info, false), (:@warn, false), + (:@err, false), (:@critical, false)]) + +end diff --git a/test/runtests.jl b/test/runtests.jl index 6f60281b..8df136a7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,3 +2,4 @@ using Logging: debug, info, warn include("log_test.jl") include("macro_test.jl") include("test_hierarchy.jl") +include("macro_scope_test.jl") From eaeceb7cb7a410e90268bfcdba89713e0357b2cd Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 16 May 2017 17:16:02 -0700 Subject: [PATCH 6/6] Update CI URLs to point to new caching infrastructure --- appveyor.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index be940168..93974cc2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,9 @@ environment: matrix: - - JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe" - - JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" - - JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe" - - JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" + - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" + - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" branches: only: @@ -17,9 +17,10 @@ notifications: on_build_status_changed: false install: + - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" # Download most recent Julia Windows binary - ps: (new-object net.webclient).DownloadFile( - $("http://s3.amazonaws.com/"+$env:JULIAVERSION), + $env:JULIA_URL, "C:\projects\julia-binary.exe") # Run installer silently, output to C:\projects\julia - C:\projects\julia-binary.exe /S /D=C:\projects\julia