Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package de.agilecoders.wicket.logging;
 
An IClientLogger is responsible for writing the log messages to the log store. Slf4j is used as default Logger implementation.

Author(s):
miha
public interface IClientLogger {

    
writes a set of log messages to the log store

Parameters:
logObjects all log messages that needs to be written
clientInfos the client information according to given logObjects.
    void log(Iterable<ClientSideLogObjectlogObjectsClientInfos clientInfos);

    
Default implementation of IClientLogger that uses slf4j as logger.
    public static class DefaultClientLogger implements IClientLogger {
        private final Logger logger;

        
Construct.

Parameters:
id the logger id
        public DefaultClientLogger(final String id) {
            this. = newLogger(id);
        }

        
creates a new slf4j logger

Parameters:
loggerName the name of the logger
Returns:
new logger
        protected Logger newLogger(String loggerName) {
            return LoggerFactory.getLogger(loggerName);
        }
        @Override
        public void log(Iterable<ClientSideLogObjectlogObjectsClientInfos clientInfos) {
            final ILogCleaner cleaner = ClientSideLoggingSettings.get().cleaner();
            for (ClientSideLogObject logObject : logObjects) {
                switch (logObject.level()) {
                    case "error":
                        if (.isErrorEnabled()) {
                            .error(newLogMessage("error"logObjectclientInfoscleaner));
                        }
                        break;
                    case "warn":
                        if (.isWarnEnabled()) {
                            .warn(newLogMessage("warn"logObjectclientInfoscleaner));
                        }
                        break;
                    case "info":
                        if (.isInfoEnabled()) {
                            .info(newLogMessage("info"logObjectclientInfoscleaner));
                        }
                        break;
                    case "debug":
                        if (.isDebugEnabled()) {
                            .debug(newLogMessage("debug"logObjectclientInfoscleaner));
                        }
                        break;
                    case "trace":
                        if (.isTraceEnabled()) {
                            .trace(newLogMessage("trace"logObjectclientInfoscleaner));
                        }
                        break;
                    default:
                }
            }
        }

        
creates a new log line

Parameters:
logLevel the current log level
logObject the log object that contains message and level
clientInfos the client information that contains user-agent and ajax base url
cleaner the log cleaner implementation
Returns:
new log message line.
        protected String newLogMessage(String logLevelClientSideLogObject logObjectClientInfos clientInfosILogCleaner cleaner) {
            return String.format("[%s] %s [%s]; Stack: %s"cleaner.toCleanPath(clientInfos.ajaxBaseUrl()), logObjectcleaner.clean(clientInfos.userAgent()), logObject.stacktrace());
        }
    }
New to GrepCode? Check out our FAQ X