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

in std/logging implement removeHandler #23757

Closed
steschuser opened this issue Jun 25, 2024 · 0 comments · Fixed by #24143
Closed

in std/logging implement removeHandler #23757

steschuser opened this issue Jun 25, 2024 · 0 comments · Fixed by #24143

Comments

@steschuser
Copy link

steschuser commented Jun 25, 2024

Summary

In the std/logging module is a addHandler proc but a corresponding removeHandler seems to be missing

Description

I'd like to remove already added handlers :)

Alternatives

No response

Examples

import std/logging

var consoleLog = newConsoleLogger()
var fileLog = newFileLogger("errors.log", levelThreshold=lvlError)
var rollingLog = newRollingFileLogger("rolling.log")

addHandler(consoleLog)
removeHandler(consoleLog)

addHandler(fileLog)
removeHandler(fileLog)

addHandler(rollingLog)

Links

https://nim-lang.org/docs/logging.html#addHandler%2CLogger

Araq added a commit that referenced this issue Sep 20, 2024
Since the module allows for a handler to be added multiple times, for
the sake of consistency, `removeHandler` only removes the first found
instance of the handler in the `handlers` seq. So for n calls of
`addHandler` using the same handler, n calls of `removeHandler` are
required.

fixes #23757

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
metagn pushed a commit to metagn/Nim that referenced this issue Sep 21, 2024
nim-lang#24143)

Since the module allows for a handler to be added multiple times, for
the sake of consistency, `removeHandler` only removes the first found
instance of the handler in the `handlers` seq. So for n calls of
`addHandler` using the same handler, n calls of `removeHandler` are
required.

fixes nim-lang#23757

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants