gelf

Members

Classes

GrayLogger
class GrayLogger

Abstract Graylog Logger

HttpGrayLogger
class HttpGrayLogger

HTTP Graylog Logger

SocketGrayLogger
class SocketGrayLogger

Abstract Socket Graylog Logger

TcpGrayLogger
class TcpGrayLogger

TCP Graylog Logger

UdpGrayLogger
class UdpGrayLogger

UDP Graylog Logger

Examples

1 // HTTP
2 import std.net.curl: HTTP;
3 Compress c; // `null` value is for no compression
4 // c = new Compress;
5 // c = new Compress(HeaderFormat.gzip);
6 sharedLog = new HttpGrayLogger(HTTP("192.168.59.103:12201/gelf"), c, "YourServiceName", LogLevel.all);
7 
8 error("===== Error Information =====");
1 import std.format: format;
2 foreach(i, c; [Compress.init, new Compress, new Compress(HeaderFormat.gzip)])
3 {
4 	auto socket = new UdpSocket();
5 	socket.connect(new InternetAddress("192.168.59.103", 12201));
6 	auto logger = new UdpGrayLogger(socket, null, "UDP%s".format(i), LogLevel.all, 512);
7 	logger.errorf("===== UDP #%s.0 =====", i);
8 	logger.errorf("===== UDP #%s.1 =====", i);
9 	logger.errorf("========== UDP #%s.3 ==========\n%s", i,
10 		"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae nisl scelerisque,
11 		vestibulum arcu quis, rhoncus leo. Nunc ullamcorper nibh vitae nisl viverra dignissim.
12 		Etiam dictum tincidunt commodo. Morbi faucibus et ipsum in hendrerit. Phasellus rutrum,
13 		lacus at auctor tempor, metus nisl suscipit nisi, elementum molestie quam enim nec erat.
14 		Sed cursus libero felis, in pulvinar neque molestie eget. Praesent pulvinar est vitae sem
15 		pulvinar, pharetra dignissim velit condimentum.
16 
17 		Vestibulum laoreet lorem eu dui ornare, ac congue enim consectetur.
18 		Morbi tincidunt, turpis et egestas sodales, erat velit suscipit felis,
19 		quis porttitor nulla turpis ut odio. Fusce in faucibus felis, ac feugiat mauris.
20 		Nullam vel sagittis mi. Nullam eu turpis ullamcorper, porta odio sit amet, dictum lorem.
21 		Nunc dictum in sem vel pharetra. In consectetur posuere massa, sed convallis felis tempus quis.
22 		Maecenas eleifend aliquam lectus pretium aliquam. Morbi viverra dui tortor,
23 		vel laoreet libero accumsan sed. Quisque congue erat quis nisl sed.");
24 }
1 auto socket = new TcpSocket();
2 socket.connect(new InternetAddress("192.168.59.103", 12202));
3 auto logger = new TcpGrayLogger(socket, "TCP", LogLevel.all);
4 logger.error("===== TCP.0 =====");
5 logger.error("===== TCP.1 =====");
6 logger.error("===== TCP.2 =====");
1 import std.format: format;
2 import std.net.curl;
3 foreach(i, c; [Compress.init, new Compress, new Compress(HeaderFormat.gzip)])
4 {
5 	auto logger = new HttpGrayLogger(HTTP("192.168.59.103:12204/gelf"), c, "HTTP%s".format(i), LogLevel.all);
6 	logger.errorf("===== HTTP #%s =====", i);
7 }
1 void t_udp()
2 {
3 	Compress c; //`null` value for no compression
4 	// c = new Compress;
5 	// c = new Compress(HeaderFormat.gzip);
6 	auto socket = new UdpSocket();
7 	socket.connect(new InternetAddress("192.168.59.103", 12201));
8 	// The last param is UDP chunk size. This is optional paramter with default value equals to 8192
9 	sharedLog = new UdpGrayLogger(socket, c, "YourServiceName", LogLevel.all, 4096);
10 	error("===== Error Information =====");
11 }
12 
13 void t_tcp()
14 {
15 	import std.typecons: Yes, No;
16 	auto socket = new TcpSocket();
17 	socket.connect(new InternetAddress("192.168.59.103", 12201));
18 	/+Defualt value for nullDelimeter is `Yes`. Newline delimiter would be used if nullDelimeter is `false`/`No`.+/
19 	sharedLog = new TcpGrayLogger(socket, "YourServiceName", LogLevel.all, Yes.nullDelimeter);
20 	error("===== Error Information =====");
21 }
22 
23 void t_http()
24 {
25 	import std.net.curl: HTTP;
26 	Compress c; //`null` value for no compression
27 	// c = new Compress;
28 	// c = new Compress(HeaderFormat.gzip);
29 	sharedLog = new HttpGrayLogger(HTTP("192.168.59.103:12204/gelf"), c, "YourServiceName", LogLevel.all);
30 	error("===== Error Information =====");
31 }

Meta