https://github.com/tk3369/modulelogging.jl
Global logging for your own modules only!
https://github.com/tk3369/modulelogging.jl
julia logging
Last synced: 25 days ago
JSON representation
Global logging for your own modules only!
- Host: GitHub
- URL: https://github.com/tk3369/modulelogging.jl
- Owner: tk3369
- License: mit
- Created: 2019-11-23T20:31:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-14T00:46:59.000Z (over 5 years ago)
- Last Synced: 2025-01-15T11:10:56.748Z (over 1 year ago)
- Topics: julia, logging
- Language: Julia
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ModuleLogging.jl
[](https://github.com/tk3369/ModuleLogging.jl/actions?query=workflow%3ACI)
This package allows selective logging by module.
One use case is to turn on debug logging only for your own modules
but not any other third-party modules.
For convenience, two constructor functions are provided.
The first one creates an underlying `SimpleLogger`.
```julia
ModuleLogger(stream::IO, level::Logging.LogLevel, modules::Module...)
ModuleLogger(logger::AbstractLogger, modules::Module...)
```
Example:
```julia
module Foo
function foo()
@debug "foo called"
return 1
end
end
module Bar
function bar()
@debug "bar called"
return 2
end
end
using Logging, ModuleLogging
using .Foo
using .Bar
# Turn on debug logging for Foo module only
logger = ModuleLogger(stderr, Logging.Debug, Foo)
global_logger(logger)
Foo.foo() # debug log is displayed
Bar.bar() # no debug log
```