// Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
//     private static final InternalLogger LOGGER = new InternalLogger() {
//         public boolean isEnabled(LogLevel level) {
//             return true;
//         }
// 
//         public void log(LogEvent logEvent) {
//             System.out.println(LogUtils.toString(logEvent));
//         }
//     };
// 
//     public InternalLogger create(String logName) {
//         return LOGGER;
//     }
// 
//     public void shutdown() {
//         // do nothing
//     }
// }
// 
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
// 
//     private static final String __prefix = "log5j.formatter.default.";
// 
//     private final Locale _locale;
// 
//     public DefaultMessageFormatterFactory() {
//         String language = System.getProperty(__prefix + "language", null);
//         String country = System.getProperty(__prefix + "country", null);
//         String variant = System.getProperty(__prefix + "variant", null);
// 
//         if (variant != null) {
//             _locale = new Locale(language, country, variant);
//         } else if (country != null) {
//             _locale = new Locale(language, country);
//         } else if (language != null) {
//             _locale = new Locale(language);
//         } else {
//             _locale = Locale.getDefault();
//         }
//     }
// 
//     public MessageFormatter create() {
//         return new DefaultMessageFormatter(_locale);
//     }
// }
// 
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
//     MessageFormatter create();
// }


import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory;
/*
 * Copyright 2010 "Tailrank, Inc (Spinn3r)"
 *
 * 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 com.spinn3r.log5j;


public class LogManager {


    private static final AsyncLogger __asyncLogger = new AsyncLogger();

    private static InternalLoggerFactory __internalLoggerFactory;

    static MessageFormatterFactory __messageFormatterFactory;

    private static volatile boolean _disableShutdownHook = false;

    private static volatile boolean _shuttingDown = false;
    
    static {
        try {
            Class<?> clazz = Class.forName(Settings.get().getFactoryClass());
            __internalLoggerFactory = (InternalLoggerFactory) clazz.newInstance();
        } catch (Throwable e) {
            System.err.println("Cannot initialize internal logger factory:");
            e.printStackTrace();
            __internalLoggerFactory = new StdoutInternalLoggerFactory();
        }

        try {
            Class<?> clazz = Class.forName(Settings.get().getFormatterFactoryClass());
// Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
//     private static final InternalLogger LOGGER = new InternalLogger() {
//         public boolean isEnabled(LogLevel level) {
//             return true;
//         }
// 
//         public void log(LogEvent logEvent) {
//             System.out.println(LogUtils.toString(logEvent));
//         }
//     };
// 
//     public InternalLogger create(String logName) {
//         return LOGGER;
//     }
// 
//     public void shutdown() {
//         // do nothing
//     }
// }
// 
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
// 
//     private static final String __prefix = "log5j.formatter.default.";
// 
//     private final Locale _locale;
// 
//     public DefaultMessageFormatterFactory() {
//         String language = System.getProperty(__prefix + "language", null);
//         String country = System.getProperty(__prefix + "country", null);
//         String variant = System.getProperty(__prefix + "variant", null);
// 
//         if (variant != null) {
//             _locale = new Locale(language, country, variant);
//         } else if (country != null) {
//             _locale = new Locale(language, country);
//         } else if (language != null) {
//             _locale = new Locale(language);
//         } else {
//             _locale = Locale.getDefault();
//         }
//     }
// 
//     public MessageFormatter create() {
//         return new DefaultMessageFormatter(_locale);
//     }
// }
// 
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
//     MessageFormatter create();
// }


// Path: src/java/com/spinn3r/log5j/LogManager.java
import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory;

/*
 * Copyright 2010 "Tailrank, Inc (Spinn3r)"
 *
 * 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 com.spinn3r.log5j;


public class LogManager {


    private static final AsyncLogger __asyncLogger = new AsyncLogger();

    private static InternalLoggerFactory __internalLoggerFactory;

    static MessageFormatterFactory __messageFormatterFactory;

    private static volatile boolean _disableShutdownHook = false;

    private static volatile boolean _shuttingDown = false;
    
    static {
        try {
            Class<?> clazz = Class.forName(Settings.get().getFactoryClass());
            __internalLoggerFactory = (InternalLoggerFactory) clazz.newInstance();
        } catch (Throwable e) {
            System.err.println("Cannot initialize internal logger factory:");
            e.printStackTrace();
            __internalLoggerFactory = new StdoutInternalLoggerFactory();
        }

        try {
            Class<?> clazz = Class.forName(Settings.get().getFormatterFactoryClass());
            __messageFormatterFactory = (MessageFormatterFactory) clazz.newInstance();