From c66123e50665d3e389b151a18a8dd24337ff9e2d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 17 Jun 2019 15:38:43 +0200 Subject: [PATCH] Deprecate verbose flag, tweak some logging code There is no point in Coverage.LCOV.readfolder and Coverage.clean_folder reporting every file they did *not* process; this just clogs up build logs, and almost always is useless; so change this from @info to @debug. Also, by default user won't want to know the JSON replies of Codecov and Coveralls, nor the exact URL we used to submit to Codecov, so change those from @info to @debug as well. On the other hand, knowing which files actually are being processed *is* useful, so add an @info message for that (I recently had an exception thrown in that code and had a hard time figuring out which file was being proceed, so this will help). Finally, deprecate the `verbose` keyword flag; instead, users should adjust the logging level to suppress or show various messages. --- src/Coverage.jl | 5 +++-- src/codecovio.jl | 26 +++++++++++++------------- src/coveralls.jl | 18 +++++++++++++++--- src/lcov.jl | 2 +- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/Coverage.jl b/src/Coverage.jl index e2c6c08..cf308de 100644 --- a/src/Coverage.jl +++ b/src/Coverage.jl @@ -133,6 +133,7 @@ module Coverage # Keep track of the combined coverage full_coverage = CovCount[] for file in files + @info "Coverage.process_cov: processing $file" coverage = CovCount[] for line in eachline(file) # Columns 1:9 contain the coverage count @@ -232,7 +233,7 @@ module Coverage where Coverage is called from the root directory of a package. """ function process_folder(folder="src") - @info """Coverage.process_folder: Searching $folder for .jl files...""" + @info "Coverage.process_folder: Searching $folder for .jl files..." source_files = FileCoverage[] files = readdir(folder) for file in files @@ -242,7 +243,7 @@ module Coverage if splitext(fullfile)[2] == ".jl" push!(source_files, process_file(fullfile, folder)) else - @info "Coverage.process_folder: Skipping $file, not a .jl file" + @debug "Coverage.process_folder: Skipping $file, not a .jl file" end elseif isdir(fullfile) # If it is a folder, recursively traverse diff --git a/src/codecovio.jl b/src/codecovio.jl index f96f54c..856bece 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -182,27 +182,24 @@ module Codecov """ function submit_generic(fcs::Vector{FileCoverage}; kwargs...) @assert length(kwargs) > 0 - dry_run = false - verbose = true - for (k,v) in kwargs - if k == :dry_run - dry_run = true - end - if k == :verbose - verbose = v - end + dry_run = get(kwargs, :dry_run, false) + if haskey(kwargs, :verbose) + Base.depwarn("The verbose keyword argument is deprecated, set the environment variable " * + "JULIA_DEBUG=Coverage for verbose output", :submit_generic) + verbose = kwargs[:verbose] + else + verbose = false end uri_str = construct_uri_string(;kwargs...) - if verbose - @info "Codecov.io API URL:\n" * mask_token(uri_str) - end + verbose && @info "Submitting data to Codecov..." + verbose && @debug "Codecov.io API URL:\n" * mask_token(uri_str) if !dry_run heads = Dict("Content-Type" => "application/json") data = to_json(fcs) req = HTTP.post(uri_str; body = JSON.json(data), headers = heads) - @info "Result of submission:" * String(req) + @debug "Result of submission:" * String(req) end end @@ -225,6 +222,9 @@ module Codecov uri_str = "$(codecov_url)/upload/v2?" for (k,v) in kwargs + # add all except a few special key/value pairs to the URL + # (:verbose is there for backwards compatibility with versions + # of this code that treated it in a special way) if k != :codecov_url && k != :dry_run && k != :verbose uri_str = "$(uri_str)&$(k)=$(v)" end diff --git a/src/coveralls.jl b/src/coveralls.jl index 51a1049..fca8986 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -56,7 +56,13 @@ module Coveralls on TravisCI, AppVeyor or Jenkins. If running locally, use `submit_local`. """ function submit(fcs::Vector{FileCoverage}; kwargs...) - verbose = get(kwargs, :verbose, true) + if haskey(kwargs, :verbose) + Base.depwarn("The verbose keyword argument is deprecated, set the environment variable " * + "JULIA_DEBUG=Coverage for verbose output", :submit_generic) + verbose = kwargs[:verbose] + else + verbose = false + end data = prepare_request(fcs, false) post_request(data, verbose) end @@ -157,8 +163,14 @@ module Coveralls git_info can be either a `Dict` or a function that returns a `Dict`. """ function submit_local(fcs::Vector{FileCoverage}, git_info=query_git_info; kwargs...) + if haskey(kwargs, :verbose) + Base.depwarn("The verbose keyword argument is deprecated, set the environment variable " * + "JULIA_DEBUG=Coverage for verbose output", :submit_generic) + verbose = kwargs[:verbose] + else + verbose = false + end data = prepare_request(fcs, true, git_info) - verbose = get(kwargs, :verbose, true) post_request(data, verbose) end @@ -166,7 +178,7 @@ module Coveralls function post_request(data, verbose) verbose && @info "Submitting data to Coveralls..." req = HTTP.post("https://coveralls.io/api/v1/jobs", HTTP.Form(makebody(data))) - verbose && @info "Result of submission:\n" * String(req.body) + verbose && @debug "Result of submission:\n" * String(req.body) end # adds the repo token to the data diff --git a/src/lcov.jl b/src/lcov.jl index 6039667..0f7e95d 100644 --- a/src/lcov.jl +++ b/src/lcov.jl @@ -130,7 +130,7 @@ function readfolder(folder) if endswith(fullfile, ".info") append!(source_files, readfile(fullfile)) else - @info "Coverage.LCOV.readfolder: Skipping $file, not a .info file" + @debug "Coverage.LCOV.readfolder: Skipping $file, not a .info file" end elseif isdir(fullfile) # If it is a folder, recursively traverse