All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudfoundry.identity.uaa.logging.SanitizedLogFactory Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package org.cloudfoundry.identity.uaa.logging;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Returns Log instance that replaces \n, \r, \t with a | to prevent log forging.
 */
public class SanitizedLogFactory {

    public static SanitizedLog getLog(Class clazz) {
        return new SanitizedLog(LogFactory.getLog(clazz));
    }

    public static class SanitizedLog {
        private Log fallback;

        public SanitizedLog(Log log) {
            this.fallback = log;
        }

        public boolean isDebugEnabled() {
            return fallback.isDebugEnabled();
        }

        public void info(String message) {
            fallback.info(LogSanitizerUtil.sanitize(message));
        }

        public void warn(String message) {
            fallback.warn(LogSanitizerUtil.sanitize(message));
        }

        public void debug(String message) {
            fallback.debug(LogSanitizerUtil.sanitize(message));
        }

        public void debug(String message, Throwable t) {
            fallback.debug(LogSanitizerUtil.sanitize(message), t);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy