Last Push

Marketplace Rating

Discussion

Readme from Github

gelfd

What is GELF?

It is an open standard logging format based on JSON. It is primarily used to pipe messages to Graylog, the open source log management and analysis platform.

Using GELF avoids the shortcomings of logging to plain syslog, most importantly the lack of a structured payload along with messages (stack traces, timeouts etc).

GELF is a pure JSON format. It describes how log messages should be structured. In addition, it also describes compression of messages and chunking of large messages over UDP.

This module aims to provide a simple, yet structured, way of generating log messages in the GELF format. You can combine messages with arbitrary payload data and construct messages in multiple parts. Message contents are also queryable. See examples below.

Usage

The simplest way to create a GELF message is as follows :

import gelf;
writeln(Message("localhost", "An alert message"));

GELF messages are composed in a Message struct. The struct supports :

opString - writing or casting to a string generates the GELF message.

opDispatch - payload data can be added using user-defined functions or properties. It can also be read as properties.

opIndexAssign - payload data can also be assigned like an associative array.

Installation

You can install this package using dub, or download the source and compile it into your program.

Using DUB

The recommended way. To include gelfd in your project follow the instructions on the project dub page

If you want to just download the source into your project directory, do this :

dub fetch gelfd --cache=local

Using DMD/LDC/GDC

Clone this repo

Compile your source with the gelf sources. dmd MYFILE.d source/gelf/*

Unittests

Run unittests like so :

dub test

Run the Example script

This script contains various examples of how to generate GELF messages. You don't need Graylog installed to check this, although it is recommended to atleast run netcat to see the output of chunked (and compressed) messages. To run example.d, do :