/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* ident "%Z%%M% %I% %E% SMI" */
/**
* This handler outputs LogRecords with <code>syslog(3C)</code> to the
* given facility with a severity translated by Level with a fixed
* table. Formatters are not used.
*
* Multiple SyslogHandlers may not be in concurrent use in one virtual
* machine.
*/
/**
* <code>syslog(3C)</code> ident string, prepended to every
* message.
*/
/**
* <code>syslog</code> facility to be logged to.
*/
/**
* Records the instance of this singleton.
*/
/**
* Flag whether stack traces should be output when a record's
* <code>thrown</code> field is set. They will be formatted in
* a single line by <code>SuccinctStackTraceFormatter</code>,
* which does not include the Throwable's description, since
* it's presumably described by the log message). Default
* <code>true</code>.
*/
private static boolean useStackTraces = true;
/**
* Default logging option value. Sets no options. (Corresponds
* to the <code>logopt</code> argument to openlog(3c).)
*/
/**
* Flag to set whether log records should indicate the record's
* logger. (default false)
*/
private boolean useLoggerName = false;
/**
* Flag to set whether log records should indicate the last
* component of the record's logger name, if useLoggerName isn't
* set. (default true)
*/
private boolean useShortLoggerName = true;
static {
}
{
throw new IllegalArgumentException();
instance = this;
}
/**
* Return this virtual machine's instance of SyslogHandler,
* creating one which logs with the given identity to the given
* facility if necessary, unless an instance with a different
* identity or facility is already open, in which case an
* IllegalArgumentException is thrown.
*
* @throws IllegalArgumentException if the requested identity or
* facility differs from a previously-created instance.
*/
{
throw new IllegalArgumentException();
else
return (instance);
} else
}
public void finalize()
{
try {
close();
} catch (Exception e) {
// superclass-defined exceptions do not apply
}
}
{
")");
}
/**
* Calls <code>syslog(3C)</code>.
*/
/**
* Calls <code>openlog(3C)</code>.
*/
int facility);
/**
* Calls <code>closelog(3C)</code>.
*/
private static native void closelog();
/**
* Publishes the given record with its associated Severity (or
* infers its severity with Severity.severityForLevel(), if
* another type of Level is used), if the result is non-null.
*/
{
else
.getLevel());
return;
/*
* If the severity is null, the message isn't meant to
* be sent to syslog.
*/
return;
if (useLoggerName) {
if (loggerName != null) {
}
} else if (useShortLoggerName) {
if (loggerName != null) {
if (lastDot >= 0)
lastDot + 1);
}
}
/*
* If the Severity is null, it's not meant to be logged
* via syslog.
*/
/*
* Format the stack trace as one line and tack
* it onto the message.
*/
"with tracing information: ").toString());
}
}
public void flush()
{
}
{
closelog();
}
}
/**
* Formatters may not be used with SyslogHandler.
*
* @throws IllegalArgumentException if the use of one is
* attempted.
*/
{
throw new IllegalArgumentException();
}
/**
* Returns the <code>syslog(3C)</code> ident string, which is
* prepended to every message.
*/
{
return (ident);
}
/**
* Returns the <code>syslog</code> facility to be logged to.
*/
{
return (facility);
}
}