package org.xbib.net.socket.systemd;

import org.xbib.net.socket.v4.unix.UnixDatagramSocket;

import java.io.IOException;
import java.net.SocketException;
import java.util.Objects;

public class SystemdJournal implements AutoCloseable {

    private final UnixDatagramSocket socket;

    public SystemdJournal() throws SocketException {
        String socketName = Objects.requireNonNull(System.getenv("JOURNAL_SOCKET"));
        this.socket = new UnixDatagramSocket(socketName);
    }

    public UnixDatagramSocket getSocket() {
        return socket;
    }

    @Override
    public void close() throws IOException {
        socket.close();
    }
}
