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