// Path: core/src/main/java/org/jboss/logmanager/ExtErrorManager.java
// public abstract class ExtErrorManager extends ErrorManager {
// 
//     /**
//      * Get the name corresponding to the given error code.
//      *
//      * @param code the error code
//      * @return the corresponding name (not {@code null})
//      */
//     protected String nameForCode(int code) {
//         switch (code) {
//             case CLOSE_FAILURE: return "CLOSE_FAILURE";
//             case FLUSH_FAILURE: return "FLUSH_FAILURE";
//             case FORMAT_FAILURE: return "FORMAT_FAILURE";
//             case GENERIC_FAILURE: return "GENERIC_FAILURE";
//             case OPEN_FAILURE: return "OPEN_FAILURE";
//             case WRITE_FAILURE: return "WRITE_FAILURE";
//             default: return "INVALID (" + code + ")";
//         }
//     }
// 
//     public void error(final String msg, final Exception ex, final int code) {
//         super.error(msg, ex, code);
//     }
// 
//     /**
//      * Convert the given error to a log record which can be published to handler(s) or stored.  Care should
//      * be taken not to publish the log record to a logger that writes to the same handler that produced the error.
//      *
//      * @param msg the error message (possibly {@code null})
//      * @param ex the error exception (possibly {@code null})
//      * @param code the error code
//      * @return the log record (not {@code null})
//      */
//     protected ExtLogRecord errorToLogRecord(String msg, Exception ex, int code) {
//         final ExtLogRecord record = new ExtLogRecord(Level.ERROR, "Failed to publish log record (%s[%d]): %s", ExtLogRecord.FormatStyle.PRINTF, getClass().getName());
//         final String codeStr = nameForCode(code);
//         record.setParameters(new Object[] {
//             codeStr,
//             Integer.valueOf(code),
//             msg,
//         });
//         record.setThrown(ex);
//         record.setLoggerName("");
//         return record;
//     }
// }


import java.util.logging.ErrorManager;
import org.jboss.logmanager.ExtErrorManager;
/*
 * JBoss, Home of Professional Open Source.
 *
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jboss.logmanager.errormanager;



/**
 * An error manager which runs only once and delegates to the given error manager.
 */
public final class OnlyOnceErrorManager extends ExtErrorManager {

    private volatile ErrorManager delegate;

    /**
     * Construct a new instance.
     *
     * @param delegate the delegate error manager
     */
    public OnlyOnceErrorManager(final ErrorManager delegate) {
        this.delegate = delegate;
    }

    /**
     * Construct a new instance with a {@link SimpleErrorManager} as a delegate.
     */
// Path: core/src/main/java/org/jboss/logmanager/ExtErrorManager.java
// public abstract class ExtErrorManager extends ErrorManager {
// 
//     /**
//      * Get the name corresponding to the given error code.
//      *
//      * @param code the error code
//      * @return the corresponding name (not {@code null})
//      */
//     protected String nameForCode(int code) {
//         switch (code) {
//             case CLOSE_FAILURE: return "CLOSE_FAILURE";
//             case FLUSH_FAILURE: return "FLUSH_FAILURE";
//             case FORMAT_FAILURE: return "FORMAT_FAILURE";
//             case GENERIC_FAILURE: return "GENERIC_FAILURE";
//             case OPEN_FAILURE: return "OPEN_FAILURE";
//             case WRITE_FAILURE: return "WRITE_FAILURE";
//             default: return "INVALID (" + code + ")";
//         }
//     }
// 
//     public void error(final String msg, final Exception ex, final int code) {
//         super.error(msg, ex, code);
//     }
// 
//     /**
//      * Convert the given error to a log record which can be published to handler(s) or stored.  Care should
//      * be taken not to publish the log record to a logger that writes to the same handler that produced the error.
//      *
//      * @param msg the error message (possibly {@code null})
//      * @param ex the error exception (possibly {@code null})
//      * @param code the error code
//      * @return the log record (not {@code null})
//      */
//     protected ExtLogRecord errorToLogRecord(String msg, Exception ex, int code) {
//         final ExtLogRecord record = new ExtLogRecord(Level.ERROR, "Failed to publish log record (%s[%d]): %s", ExtLogRecord.FormatStyle.PRINTF, getClass().getName());
//         final String codeStr = nameForCode(code);
//         record.setParameters(new Object[] {
//             codeStr,
//             Integer.valueOf(code),
//             msg,
//         });
//         record.setThrown(ex);
//         record.setLoggerName("");
//         return record;
//     }
// }


// Path: core/src/main/java/org/jboss/logmanager/errormanager/OnlyOnceErrorManager.java
import java.util.logging.ErrorManager;
import org.jboss.logmanager.ExtErrorManager;

/*
 * JBoss, Home of Professional Open Source.
 *
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jboss.logmanager.errormanager;



/**
 * An error manager which runs only once and delegates to the given error manager.
 */
public final class OnlyOnceErrorManager extends ExtErrorManager {

    private volatile ErrorManager delegate;

    /**
     * Construct a new instance.
     *
     * @param delegate the delegate error manager
     */
    public OnlyOnceErrorManager(final ErrorManager delegate) {
        this.delegate = delegate;
    }

    /**
     * Construct a new instance with a {@link SimpleErrorManager} as a delegate.
     */
    public OnlyOnceErrorManager() {