An open API service indexing awesome lists of open source software.

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.

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).