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

Support arbitrary loggers #92

Open
Djoop opened this issue May 4, 2021 · 2 comments
Open

Support arbitrary loggers #92

Djoop opened this issue May 4, 2021 · 2 comments

Comments

@Djoop
Copy link

Djoop commented May 4, 2021

Hi, in the current version of the package in train.jl there are these few lines

    if Logging.global_logger().min_level  Logging.Debug
        loglevel = :iter
    elseif Logging.global_logger().min_level  Logging.Info
        loglevel = :final
    else
        loglevel = :none
    end

which prevent from using the module with e.g. loggers from LoggingExtras (which do not all have a min_level attribute). As it seems that this loglevel is only used to call the Clustering package, wouldn't it be cleaner to simply leave Clustering deal with its logging level? Or is there a standard way in the API to do that? I see in the docs that there is a min_enabled_level which might help, not sure if it's exactly the same though.

@ForceBru
Copy link

ForceBru commented Jul 15, 2021

This also doesn't let me silence the logger. I need to fit thousands of mixtures and don't want any output while fitting individual mixtures - otherwise there's too much output, and it also slows everything down.

I tried to use a logger with a very high level, but it still prints logs from k-means:

with_logger(SimpleLogger(stdout, Logging.LogLevel(50))) do
    GMM(N_COMPONENTS, data, nIter=1000)
end

This outputs:

K-means converged with 11 iterations (objv = 47.97814024236598)

Looks like I can't influence that log level because the code is querying the global logger directly with Logging.global_logger()


I found a way of silencing logging by temporarily changing the global logger:

prev_logger = global_logger(SimpleLogger(devnull, Logging.LogLevel(50)))
result = run_many_gmms(GMM, data, N_COMPONENTS)
global_logger(prev_logger);

@davidavdav
Copy link
Owner

I never understand these logging interfaces. If you have a more satisfactory solution, please submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants