https://github.com/ghost91-/vibe-json-log
A JSON based logger for vibe-core.
https://github.com/ghost91-/vibe-json-log
json logger logging vibe-d
Last synced: about 1 month ago
JSON representation
A JSON based logger for vibe-core.
- Host: GitHub
- URL: https://github.com/ghost91-/vibe-json-log
- Owner: ghost91-
- License: mit
- Created: 2019-06-18T00:30:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-18T01:00:41.000Z (almost 6 years ago)
- Last Synced: 2025-01-20T17:41:07.951Z (3 months ago)
- Topics: json, logger, logging, vibe-d
- Language: D
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vibe-json-log
A JSON based logger for [vibe-core](https://github.com/vibe-d/vibe-core).
## Usage
To use the logger in your [vibe-core](https://github.com/vibe-d/vibe-core) based
project, simply register it as a logger:```D
import vibe.core.log : registerLogger;
import vibe_json_log.log : JSONLogger;registerLogger(cast(shared) new JSONLogger());
```The no argument constructor creates a `JSONLogger` that logs to `stdout` and
`stderr` depending on the loglevel. You can log to specific files using the
other overloads:```D
import std.stdio : File;
import vibe_json_log.log : JSONLogger;new JSONLogger(File("path/to/infoFile.log", "ab"), File("path/to/errorFile.log", "ab"));
new JSONLogger("path/to/logFile.log");
```
## Format
The format of the log messages is described in
[log-message.schema.json](log-message.schema.json). Here is an example of how a
log message could look like:```json
{
"timestamp": "2019-06-17T23:47:42.6605845Z",
"threadName": "main",
"threadID": "A6A7AF69",
"taskID": "Aud+-fin",
"level": "TRACE",
"file": "../../.dub/packages/vibe-core-1.6.2/vibe-core/source/vibe/core/sync.d",
"line": 1047,
"message": "emit shared done"
}
```## Acknowledgement
This project is heavily based on the `FileLoger` which is distributed as part of
[vibe-core](https://github.com/vibe-d/vibe-core). You can find the corresponding
license [here](https://github.com/vibe-d/vibe-core/blob/master/LICENSE.txt).