vibe-json-log

A JSON based logger for vibe-core.


Keywords
library, json, logger, logging, vibe-d
License
MIT
Install
dub fetch vibe-json-log --version 0.1.2

Documentation

vibe-json-log

A JSON based logger for vibe-core.

Usage

To use the logger in your vibe-core based project, simply register it as a logger:

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:

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. Here is an example of how a log message could look like:

{
    "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. You can find the corresponding license here.