protected static void write(int level, String message, UnixSyslogConfig config) throws SyslogRuntimeException { synchronized (libraryInstance) { if (currentFacility != config.getFacility()) { if (openlogCalled) { libraryInstance.closelog(); openlogCalled = false; } currentFacility = config.getFacility(); } if (!openlogCalled) { String ident = config.getIdent(); if (ident != null && "".equals(ident.trim())) { ident = null; } Memory identBuffer = ident == null ? null : (Memory) identMap.get(ident); if (ident != null && identBuffer == null) { identBuffer = new Memory(128); identBuffer.setString(0, ident, false); identMap.put(ident, identBuffer); } libraryInstance.openlog(identBuffer, config.getOption(), currentFacility); openlogCalled = true; } int priority = currentFacility | level; libraryInstance.syslog(priority, "%s", message); } }
public void flush() throws SyslogRuntimeException { synchronized (libraryInstance) { libraryInstance.closelog(); openlogCalled = false; } }