invenia / Memento.jl

A flexible logging library for Julia
https://invenia.github.io/Memento.jl/latest
Other
88 stars 14 forks source link

Renamed a significant part of the API to be more julian #51

Closed rofinn closed 6 years ago

rofinn commented 6 years ago

Closes #31

Main changes include:

  1. Removing _ from public method names
  2. Adding ! to mutating methods
  3. Removing add_handler and remove_handler in favour of push!(logger, handler). I'll be replacing the internal handler Dict with a Vector in a future release.
  4. Overloaded += for adding handlers and filters to loggers (or filters to handlers).
codecov[bot] commented 6 years ago

Codecov Report

Merging #51 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #51   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           8      8           
  Lines         200    211   +11     
=====================================
+ Hits          200    211   +11
Impacted Files Coverage Δ
src/deprecated.jl 100% <ø> (ø) :arrow_up:
src/Memento.jl 100% <ø> (ø) :arrow_up:
src/handlers.jl 100% <100%> (ø) :arrow_up:
src/loggers.jl 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 407ab60...26db95b. Read the comment docs.

rofinn commented 6 years ago

The argument around + is that it fits with some other packages in the julia ecosystem (e.g., adding constraints in Convex.jl).

iamed2 commented 6 years ago

Convex uses that out of deference to MATLAB syntax used in its predecessors. Julia has many more options available including functions that mutate their arguments (+ was used in MATLAB because all MATLAB functions took arguments as copy-on-write).

rofinn commented 6 years ago

Ahh, okay, I didn't realize that choice was based on MATLAB syntax. I did notice that having a shorthand for push!(logger, handler) was nice when you have complicated handler constructors, but I suppose that isn't necessary for this PR. Maybe @omus has an opinion on this?

I'll note that several other languages have a shorthand for pushing elements onto a list:

swift: names += ["Fred"] haskel: names ++ ["Fred"] ruby: names << "Fred" ocaml: names@["Fred"] julia: names <! "Fred"?

omus commented 6 years ago

I think we can just stick with push! since a mutating += is a little weird (I was alright with it originally since Convex.jl was doing it). I think having a shorthand would be nice but I we can open an issue and wait until we come up with something solid.

rofinn commented 6 years ago

@iamed2 and @omus Is this good to merge?