https://github.com/julialogging/sysloglogging.jl
Syslog Logger for Julia
https://github.com/julialogging/sysloglogging.jl
Last synced: 6 months ago
JSON representation
Syslog Logger for Julia
- Host: GitHub
- URL: https://github.com/julialogging/sysloglogging.jl
- Owner: JuliaLogging
- License: other
- Created: 2020-03-18T11:28:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-05T05:35:49.000Z (over 6 years ago)
- Last Synced: 2025-02-21T07:17:28.962Z (over 1 year ago)
- Language: Julia
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SyslogLogging
[](https://travis-ci.org/tanmaykm/SyslogLogging.jl)
[](https://coveralls.io/github/tanmaykm/SyslogLogging.jl?branch=master)
Provides an implementation of `AbstractLogger` that can log into syslog. The syslog interface is based on [Syslogs.jl](https://github.com/invenia/Syslogs.jl).
### Usage:
```julia
julia> using SyslogLogging, Logging
julia> logger = SyslogLogger("myapplication", Logging.Info);
julia> with_logger(logger) do
@info("hello syslog")
@warn("hello", p1=100, d=Dict("a"=>1, "b"=>2))
end
shell> tail -2 /var/log/syslog
Mar 18 18:30:33 tanlto myapplication: Info: hello syslog [Main REPL[4]:2]
Mar 18 18:30:33 tanlto myapplication: Warning: hello [Main REPL[4]:3], [p1=100], [d=Dict("a"=>1,"b"=>2)]
```
#### Using Remote Syslog Servers
To use a remote syslog server, provide the connection parameters in addition to the logging identity.
```
julia> logger = SyslogLogger("myapplication", Logging.Info; host=ip"127.0.0.1", port=514, tcp=false)
```
#### Using Multiple Instances
Applications should ideally have only one instance of `SyslogLogger`, and use keywords instead to differentiate between log identities. But if an application must use multiple instances of `SyslogLogger` with different identities to operate parallely, it may provide a lock to be used by the loggers. Otherwise, because the underlying syslog library provides only one context, there is a chance that the identities may get mixed up. Providing a `ReentrantLock` with the `lck` keyword would prevent that. E.g.:
```julia
julia> using SyslogLogging, Logging
julia> lck = ReentrantLock();
julia> logger1 = SyslogLogger("sysloglogger1"; lck=lck);
julia> logger2 = SyslogLogger("sysloglogger2"; lck=lck);
```