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

Change name from TeeLogger? #1

Closed
oxinabox opened this issue Sep 19, 2018 · 11 comments · Fixed by #22
Closed

Change name from TeeLogger? #1

oxinabox opened this issue Sep 19, 2018 · 11 comments · Fixed by #22
Milestone

Comments

@oxinabox
Copy link
Member

When I came up with the name DemuxLogger,
I was thinking that it would do the routing itself.
Taking in both rules, and loggers.

But it is easier to just leave the rules to the filtered logger.

I am not sure what is a better name for this

@c42f
Copy link
Member

c42f commented Oct 18, 2018

Possibilities...

  • SplittingLogger?
  • TeeLogger — in analogy with the unix tee for pipes?

@oxinabox
Copy link
Member Author

Go's log15 library calls this a Multihandler https://github.com/inconshreveable/log15/blob/master/handler.go#L200
Along those lines we would call it a MultiLogger
Which is not bad

@c42f
Copy link
Member

c42f commented Apr 23, 2019

+1 for MultiLogger

@tkf
Copy link

tkf commented Oct 23, 2019

I'm +1 for TeeLogger, as I can imagine another logger wrapping multiple loggers that uses the fist matched logger. It can be used as, e.g., SwitchLogger(ProgressLogger(...), TBLogger(...), global_logger()), to let special loggers handle special log events. To be more precise, the implementation would be something like

function handle_message(logger::SwitchLogger, args...; kwargs...)
    i = findfirst(l -> comp_shouldlog(l, args...), logger.logging)
    i === nothing && return
    return handle_message(logger.logging[i], args...; kwargs...)
end

@oxinabox
Copy link
Member Author

I would not call that SwitchLogger but it is beyond the scope of this Issue.

@tkf
Copy link

tkf commented Oct 23, 2019

The main reason I brought this up was to highlight that the name MultiLogger does not specify the functionality uniquely.

@c42f
Copy link
Member

c42f commented Oct 24, 2019

As noted on #22, I'm fine with the name TeeLogger, but neither do I really love it in the sense that I can't yet see it's an "obviously right" consistent and clear choice.

In particular, considering Mux vs Demux naming, what would be the equivalent of Mux? A "tee" can either join or split the flow; there's nothing in the naming to suggest which we are doing. (Though there's the analogy to the unix pipe utility tee which is a splitting tee.) But maybe this is a non-issue, given that the current design is "sink-centric" in the sense that any AbstractLogger needs a handle_message, and therefore can act to join several log streams.

I did like MultiLogger but @tkf's point in #1 (comment) seems somewhat convincing.

@tkf
Copy link

tkf commented Oct 24, 2019

As noted on #22, I'm fine with the name TeeLogger, but neither do I really love it in the sense that I can't yet see it's an "obviously right" consistent and clear choice.

Actually my +1 to TeeLogger is similar. I'm not sure if I thought it was obvious if I didn't know the tee command.

I think that DemuxLogger can be characterized as a logger that sends the message to all child/inner loggers [1]. Can we have a name describing this aspect? How about:

  • BroadcastLogger
  • MulticastLogger
  • (One)ToManyLogger
  • DistributingLogger
  • FanOutLogger

[1] Since the filtering happens in handle_message(demux::DemuxLogger, ...), it may not be appropriate/obvious to say that a DemuxLogger sends message to all inner loggers. However, if we formalize the API such that the filtering is done by each logger, i.e.,

function maybe_handle_message(logger, args...; kwargs...)
    if comp_handle_message_check(logger, args...; kwargs...)
        handle_message(logger, args...; kwargs...)
    end
end

then DemuxLogger can be implemented as "a logger that sends the message to all child/inner loggers"

function handle_message(demux::DemuxLogger, args...; kwargs...)
    for logger in demux.loggers
        maybe_handle_message(logger, args...; kwargs...)
    end
end

@c42f
Copy link
Member

c42f commented Oct 24, 2019

OneToManyLogger and FanOutLogger are pretty jargon free which I like. I think the others may be considered ambiguous or jargony (DistributingLogger - not related to distributed processing; BroadcastLogger - not related to broadcast; MulticastLogger - a bit jargony)

@c42f
Copy link
Member

c42f commented Oct 24, 2019

Having said that, we could have MultiLogger if we allow the handle_message to be customized via a closure. This would unify the proposed TeeLogger and SwitchLogger (cf, #23 (comment))

@oxinabox
Copy link
Member Author

MuxLogger is achieved via passing the same child to many parents

See #19

@oxinabox oxinabox changed the title Change name from DemuxLogger? Change name from TeeLogger? Oct 24, 2019
@oxinabox oxinabox reopened this Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants