Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/varon/fslogger
A rich, simple, and efficient purely functional micro logging library for F#
https://github.com/varon/fslogger
fsharp logger logging logging-library logs
Last synced: 23 days ago
JSON representation
A rich, simple, and efficient purely functional micro logging library for F#
- Host: GitHub
- URL: https://github.com/varon/fslogger
- Owner: varon
- License: mit
- Created: 2016-04-19T09:35:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-22T13:48:56.000Z (6 months ago)
- Last Synced: 2024-09-18T08:49:52.129Z (about 2 months ago)
- Topics: fsharp, logger, logging, logging-library, logs
- Language: F#
- Homepage:
- Size: 365 KB
- Stars: 12
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# F#ing Simple Logger
An rich, simple, and efficient micro logging library for F#.
This isn't frequently updated because it's literally perfect (well, probably, almost).
This is used in several production systems. It's great. It's perfect, and you should use it!
## Is this any good?
f
Yes and you should use it.## Is this still maintained?
Yes, as of 2024 - we're just mostly feature complete here. How complicated could logging be anyway?
## Installation
You can install it via NuGet. You should already know how to do that.
This runs on .NET Core, 6.0, 7.0, 8.0, etc. Go forth and use it.## HOW TO LOG STUFF:
```fsharp
let smartDevCount = 5
let devCount = 5open FSLogger
let log = Logger.ColorConsole
log.I "Uzing da librariez" // log to infolet descr = "best"
log.N $"This is the ${descr} library" // log to notice using 5.0-style interpolation```
## Is that it?
Okay fine. The library can do a bunch of stuff.
Also has some nice colour output by default.
## More examples
### Setting a path to log stuff to:
```fsharp
open FSLoggerlet log =
Logger.ColorConsole
|> Logger.withPath "MyApp"module SeriousBusiness =
let doStuff (log: Logger) (aNumber: int) =
// shadow with a better path
let log = log |> Logger.appendPath "doStuff"
if aNumber > 5 then
log.W $"Oh no, {aNumber} is bigger than 5!"
// do something important
ignore aNumber
```### Adding a custom consumer:
```fsharp
let enterpriseConsumer (l:LogEntry) =
match l.Level with
| LogLevel.Warn -> callManagement(l.Message)
| LogLevel.Error -> blameAnotherDeveloper(l.Message)
| LogLevel.Fatal -> submitNewJobApplication()
| _ -> () // ignore the restlet log =
Logger.Console
|> Logger.addConsumer enterpriseConsumer
```## I want more examples!
[Read the source code! It's super simple and documented.](https://github.com/varon/FSLogger/blob/master/src/FSLogger/Logger.fs)