-
Notifications
You must be signed in to change notification settings - Fork 21
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
TeeLogger does not work with JULIA_DEBUG? #20
Comments
Reading related posts, it seems that So, maybe LoggingExtras.jl does not have to support it. It would still be nice to mention this in the documentation and provide an alternative. |
Until today I didn't entirely understand JULIA_DEBUG. At first I assumed it didn't work because the behavour was baked into the the Some preamble: LoggingExtras basically exists to solve
Doing this kind of configuration via enviroment variables is just too hard to be specific. The Logging Extras Philosophy is that Sinks should accept everything that is given to them. Anyway, with the preamble covered: What is going on is: julia> global_logger(DemuxLogger(NullLogger()))
ConsoleLogger(Base.TTY(RawFD(0x00000010) open, 0 bytes waiting), Info, Logging.default_metafmt, true, 0, Dict{Any,Int64}())
julia> lg = current_logger()
DemuxLogger(Base.CoreLogging.AbstractLogger[Base.CoreLogging.NullLogger(), ConsoleLogger(Base.TTY(
RawFD(0x00000010) open, 0 bytes waiting), Info, Logging.default_metafmt, true, 0, Dict{Any,Int64}(
))])
julia> lg.loggers
2-element Array{Base.CoreLogging.AbstractLogger,1}:
Base.CoreLogging.NullLogger()
ConsoleLogger(Base.TTY(RawFD(0x00000010) open, 0 bytes waiting), Info, Logging.default_metafmt, true, 0, Dict{Any,Int64}())
julia> Logging.min_enabled_level(lg)
Info
julia> Logging.min_enabled_level(lg.loggers[1])
AboveMaxLevel
julia> Logging.min_enabled_level(lg.loggers[2])
Info What **(This bit makes me kinda frustrated. We have a logging system that includes a place to make this check in the loggers, but rather than using them, that feature just bypasses them entirely. The way to do this: using Logging, LoggingExtras
ENV["JULIA_DEBUG"] = "" # this thing is a mess, don't touch it.
sink = ConsoleLogger(stderr, Logging.BelowMinLevel) # A proper sink
apply_filter(child) = EarlyFilteredLogger(child) do log
log._module==Main || log.level > Logging.Debug
end
composed_logger = apply_filter(DemuxLogger(NullLogger(), sink; include_current_global=false))
global_logger(composed_logger) What do do from here, idk.
I lean towards the later. |
We also could provide a function that interprets the string in |
I think it would be great. I think all
I don't think But I think the tricky part might be for getting the "child/inner logger" that is wrapped by the filtering logger. That is to say, I think we need a function (say) function setdebug(modules::Module...)
inner_logger = global_inner_logger()
composed_logger = EarlyFilteredLogger(inner_logger) do log
log._module in modules || log.level > Logging.Debug
end
global_logger(composed_logger)
end
global_inner_logger() = ??? One way to implement this might be to create a special logger type function setdebug(modules::Module...)
inner_logger = global_inner_logger()
composed_logger = DebugLogger(modules, inner_logger)
global_logger(composed_logger)
end
global_inner_logger() = something(inner_logger_of(DebugLogger, global_logger()), global_logger())
inner_logger_of(T, logger) = ... where |
what is the motivation for doing interactively? My experience from Memento has been that configuring your logging up front at the start, then never change it. Lets open another issue for any further discussion of traversing the logging tree. And focus this on things closely related to |
I thought the whole reason why Interactive usage is also mentioned in the documentation now: JuliaLang/julia#33513. I also find it handy to change the log level interactively in the REPL. I think some long-running services support changing log level dynamically, e.g., using SIGUSR1/SIGUSR2. |
Sorry guys I don't have time to give this my full attention today. A grab bag of thoughts: I do feel that I've been musing about how to replace The main difference with |
It was frustrating to (retrospectively) see a feature creep of
Naively thinking, "local by default" sounds like a nice guideline (e.g., Julia uses struct SingletonLogger <: AbstractLogger end
handle_message(::SingletonLogger, args...; kwargs...) =
handle_message(_LOGGER, args...; kwargs...)
# ...and so on...
const _LOGGER = Ref{Any}()
setsingletonlogger(logger) = _LOGGER[] = logger I think the other way around is impossible. |
Yes |
JULIA_DEBUG can be enabled with the patch #84 . And, moreover, in fact, the function The question is why we have a configurable Debug level as the only exceptional processing?... Why don't we have a mechanism with configurable levels per class like in Java (a module in the Julia case)? The sample of the XML config with example of three different levels for <configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%kvp- %msg%n
</pattern>
</encoder>
</appender>
<logger name="chapters.configuration" level="INFO" />
<logger name="chapters.configuration.Foo" level="DEBUG" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>
For that, we need to keep somewhere a Dict of modules and log-levels. And, probably, rethink about |
We don't need a dict of levels. EarlyFilteredLogger(sink) do log
log._module == Configuration && log.level >= Info() ||
log._module == Foo && log.level >= Debug() ||
log.level >= Warn()
end Anyway the JULIA_DEBUG issue is fixed. |
I thought
global_logger(DemuxLogger(NullLogger()))
would be a no-op. However,@debug
stopped working after this.The text was updated successfully, but these errors were encountered: