org.apache.velocity.runtime.log.LogChute Java Examples

The following examples show how to use org.apache.velocity.runtime.log.LogChute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SLF4JLogChute.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * @see LogChute#isLevelEnabled(int)
 */
public boolean isLevelEnabled(int level) {
    switch (level) {
        case LogChute.DEBUG_ID:
            return log.isDebugEnabled();
        case LogChute.INFO_ID:
            return log.isInfoEnabled();
        case LogChute.TRACE_ID:
            return log.isTraceEnabled();
        case LogChute.WARN_ID:
            return log.isWarnEnabled();
        case LogChute.ERROR_ID:
            return log.isErrorEnabled();
        default:
            return true;
    }
}
 
Example #2
Source File: SLF4JLogChute.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * @see LogChute#isLevelEnabled(int)
 */
public boolean isLevelEnabled(int level) {
    switch (level) {
        case LogChute.DEBUG_ID:
            return log.isDebugEnabled();
        case LogChute.INFO_ID:
            return log.isInfoEnabled();
        case LogChute.TRACE_ID:
            return log.isTraceEnabled();
        case LogChute.WARN_ID:
            return log.isWarnEnabled();
        case LogChute.ERROR_ID:
            return log.isErrorEnabled();
        default:
            return true;
    }
}
 
Example #3
Source File: SLF4JLogChute.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * @see LogChute#log(int, String, Throwable)
 */
public void log(int level, String message, Throwable t) {
    switch (level) {
        case LogChute.WARN_ID:
            log.warn(message, t);
            break;
        case LogChute.INFO_ID:
            log.info(message, t);
            break;
        case LogChute.TRACE_ID:
            log.trace(message, t);
            break;
        case LogChute.ERROR_ID:
            log.error(message, t);
            break;
        case LogChute.DEBUG_ID:
        default:
            log.debug(message, t);
            break;
    }
}
 
Example #4
Source File: SLF4JLogChute.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * @see LogChute#log(int, String)
 */
public void log(int level, String message) {
    switch (level) {
        case LogChute.WARN_ID:
            log.warn(message);
            break;
        case LogChute.INFO_ID:
            log.info(message);
            break;
        case LogChute.TRACE_ID:
            log.trace(message);
            break;
        case LogChute.ERROR_ID:
            log.error(message);
            break;
        case LogChute.DEBUG_ID:
        default:
            log.debug(message);
            break;
    }
}
 
Example #5
Source File: CustomTitle.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Collect possible warnings and errors to own buffer
 * 
 * @param logLevel   the loglevel of the provided message
 * @param logMessage the message to log itself
 */
@Override
public void log (int logLevel, String logMessage) {
	if (logTo != null) {
		String	label;

		if (logLevel == LogChute.WARN_ID) {
			label = "WARNING";
		} else if (logLevel == LogChute.ERROR_ID) {
			label = "ERROR";
		} else {
			label = null;
		}
		if (label != null) {
			logTo.append ("[" + label + "]: " + logMessage + "\n");
		}
	}
}
 
Example #6
Source File: Slf4jLogChute.java    From minnal with Apache License 2.0 6 votes vote down vote up
/**
 * Send a log message from Velocity.
 */
public void log(int level, String message)
{
    switch (level)
    {
        case LogChute.WARN_ID:
            log.warn(message);
            break;
        case LogChute.INFO_ID:
            log.info(message);
            break;
        case LogChute.TRACE_ID:
            log.trace(message);
            break;
        case LogChute.ERROR_ID:
            log.error(message);
            break;
        case LogChute.DEBUG_ID:
        default:
            log.debug(message);
            break;
    }
}
 
Example #7
Source File: Slf4jLogChute.java    From minnal with Apache License 2.0 6 votes vote down vote up
/**
 * Send a log message from Velocity with an error.
 */
public void log(int level, String message, Throwable t)
{
    switch (level)
    {
        case LogChute.WARN_ID:
            log.warn(message, t);
            break;
        case LogChute.INFO_ID:
            log.info(message, t);
            break;
        case LogChute.TRACE_ID:
            log.trace(message, t);
            break;
        case LogChute.ERROR_ID:
            log.error(message, t);
            break;
        case LogChute.DEBUG_ID:
        default:
            log.debug(message, t);
            break;
    }
}
 
Example #8
Source File: RtgVelocityLogChuteTest.java    From rtg-tools with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void test() {
  final MemoryPrintStream mps = new MemoryPrintStream();
  Diagnostic.setLogStream(mps.printStream());
  try {
    final RtgVelocityLogChute chute = new RtgVelocityLogChute();
    chute.log(LogChute.TRACE_ID, "not gonna log");
    chute.log(LogChute.DEBUG_ID, "totally logged");
    assertFalse(chute.isLevelEnabled(LogChute.TRACE_ID));
    assertTrue(chute.isLevelEnabled(LogChute.DEBUG_ID));
    assertTrue(chute.isLevelEnabled(LogChute.INFO_ID));
  } finally {
    Diagnostic.setLogStream();
  }
  assertFalse(mps.toString().contains("not gonna log"));
  assertTrue(mps.toString().contains("totally logged"));
}
 
Example #9
Source File: SLF4JLogChute.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * @see LogChute#log(int, String, Throwable)
 */
public void log(int level, String message, Throwable t) {
    switch (level) {
        case LogChute.WARN_ID:
            log.warn(message, t);
            break;
        case LogChute.INFO_ID:
            log.info(message, t);
            break;
        case LogChute.TRACE_ID:
            log.trace(message, t);
            break;
        case LogChute.ERROR_ID:
            log.error(message, t);
            break;
        case LogChute.DEBUG_ID:
        default:
            log.debug(message, t);
            break;
    }
}
 
Example #10
Source File: SLF4JLogChute.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * @see LogChute#log(int, String)
 */
public void log(int level, String message) {
    switch (level) {
        case LogChute.WARN_ID:
            log.warn(message);
            break;
        case LogChute.INFO_ID:
            log.info(message);
            break;
        case LogChute.TRACE_ID:
            log.trace(message);
            break;
        case LogChute.ERROR_ID:
            log.error(message);
            break;
        case LogChute.DEBUG_ID:
        default:
            log.debug(message);
            break;
    }
}
 
Example #11
Source File: VelocityLogChute.java    From watcher with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isLevelEnabled(int level) {
    switch (level) {
        case LogChute.DEBUG_ID:
            return logger.isDebugEnabled();
        case LogChute.INFO_ID:
            return logger.isInfoEnabled();
        case LogChute.TRACE_ID:
            return logger.isTraceEnabled();
        case LogChute.WARN_ID:
            return logger.isWarnEnabled();
        case LogChute.ERROR_ID:
            return logger.isErrorEnabled();
        default:
            return true;
    }
}
 
Example #12
Source File: VelocityLogChute.java    From watcher with Apache License 2.0 6 votes vote down vote up
@Override
public void log(int level, String message, Throwable t) {
    switch (level) {
        case LogChute.WARN_ID:
            logger.warn(message, t);
            break;
        case LogChute.INFO_ID:
            logger.info(message, t);
            break;
        case LogChute.TRACE_ID:
            logger.trace(message, t);
            break;
        case LogChute.ERROR_ID:
            logger.error(message, t);
            break;
        case LogChute.DEBUG_ID:
        default:
            logger.debug(message, t);
            break;
    }
}
 
Example #13
Source File: VelocityLogChute.java    From watcher with Apache License 2.0 6 votes vote down vote up
@Override
public void log(int level, String message) {
    switch (level) {
        case LogChute.WARN_ID:
            logger.warn(message);
            break;
        case LogChute.INFO_ID:
            logger.info(message);
            break;
        case LogChute.TRACE_ID:
            logger.trace(message);
            break;
        case LogChute.ERROR_ID:
            logger.error(message);
            break;
        case LogChute.DEBUG_ID:
        default:
            logger.debug(message);
            break;
    }
}
 
Example #14
Source File: VelocitySlf4JLogSystem.java    From feeyo-hlsserver with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isLevelEnabled(int level) {
    switch (level) {
        case LogChute.DEBUG_ID:
            return LOGGER.isDebugEnabled();
        case LogChute.INFO_ID:
            return LOGGER.isInfoEnabled();
        case LogChute.TRACE_ID:
            return LOGGER.isTraceEnabled();
        case LogChute.WARN_ID:
            return LOGGER.isWarnEnabled();
        case LogChute.ERROR_ID:
            return LOGGER.isErrorEnabled();
        default:
            return true;
    }
}
 
Example #15
Source File: VelocitySlf4JLogSystem.java    From feeyo-hlsserver with Apache License 2.0 6 votes vote down vote up
@Override
public void log(int level, String message, Throwable t) {
    switch (level) {
        case LogChute.WARN_ID:
            LOGGER.warn(message, t);
            break;
        case LogChute.INFO_ID:
            LOGGER.info(message, t);
            break;
        case LogChute.TRACE_ID:
            LOGGER.warn(message, t);
            break;
        case LogChute.ERROR_ID:
            LOGGER.error(message, t);
            break;
        case LogChute.DEBUG_ID:
        default:
            LOGGER.debug(message, t);
            break;
    }
}
 
Example #16
Source File: VelocitySlf4JLogSystem.java    From feeyo-hlsserver with Apache License 2.0 6 votes vote down vote up
@Override
public void log(int level, String message) {
    switch (level) {
        case LogChute.WARN_ID:
            LOGGER.warn(message);
            break;
        case LogChute.INFO_ID:
            LOGGER.info(message);
            break;
        case LogChute.TRACE_ID:
            LOGGER.trace(message);
            break;
        case LogChute.ERROR_ID:
            LOGGER.error(message);
            break;
        case LogChute.DEBUG_ID:
        default:
            LOGGER.debug(message);
            break;
    }
}
 
Example #17
Source File: Slf4jLogChute.java    From minnal with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the specified log level is enabled.
 */
public boolean isLevelEnabled(int level)
{
    switch (level)
    {
        case LogChute.DEBUG_ID:
            return log.isDebugEnabled();
        case LogChute.INFO_ID:
            return log.isInfoEnabled();
        case LogChute.TRACE_ID:
            return log.isTraceEnabled();
        case LogChute.WARN_ID:
            return log.isWarnEnabled();
        case LogChute.ERROR_ID:
            return log.isErrorEnabled();
        default:
            return true;
    }
}
 
Example #18
Source File: ExtensionManager.java    From jsqsh with Apache License 2.0 5 votes vote down vote up
private String logPrefix(int level) {
    
    switch (level) {
        
        case LogChute.TRACE_ID: return "TRACE";
        case LogChute.DEBUG_ID: return "DEBUG";
        case LogChute.INFO_ID: return "INOF";
        case LogChute.WARN_ID: return "WARN";
        case LogChute.ERROR_ID: return "ERROR";
        default:
            return "UNKNOWN";
    }
}
 
Example #19
Source File: Slf4jLogChute.java    From minnal with Apache License 2.0 5 votes vote down vote up
/********** LogChute methods *************/

    public void init(RuntimeServices rs)
    {
        String name =
            (String)rs.getProperty(LOGCHUTE_SLF4J_NAME);

        if (name == null)
        {
            name = DEFAULT_LOG_NAME;
        }
        log = LoggerFactory.getLogger(name);
        log(LogChute.DEBUG_ID, "Slf4jLogChute name is '" + name + "'");
    }
 
Example #20
Source File: MojoLogChute.java    From appbundle-maven-plugin with Apache License 2.0 5 votes vote down vote up
public boolean isLevelEnabled(int i) {
    switch(i) {
        case LogChute.TRACE_ID: return false;
        case LogChute.DEBUG_ID: return mojo.getLog().isDebugEnabled();
        case LogChute.INFO_ID: return mojo.getLog().isInfoEnabled();
        case LogChute.WARN_ID: return mojo.getLog().isWarnEnabled();
        case LogChute.ERROR_ID: return mojo.getLog().isErrorEnabled();
        default: return false;
    }
}
 
Example #21
Source File: MojoLogChute.java    From appbundle-maven-plugin with Apache License 2.0 5 votes vote down vote up
public void log(int i, String string, Throwable thrwbl) {
    switch(i) {
        case LogChute.TRACE_ID: mojo.getLog().debug(string, thrwbl); break;
        case LogChute.DEBUG_ID: mojo.getLog().debug(string, thrwbl); break;
        case LogChute.INFO_ID: mojo.getLog().info(string, thrwbl); break;
        case LogChute.WARN_ID: mojo.getLog().warn(string, thrwbl); break;
        case LogChute.ERROR_ID: mojo.getLog().error(string, thrwbl); break;
        default: mojo.getLog().debug(string, thrwbl);
    }
}
 
Example #22
Source File: MojoLogChute.java    From appbundle-maven-plugin with Apache License 2.0 5 votes vote down vote up
public void log(int i, String string) {
    switch(i) {
        case LogChute.TRACE_ID: mojo.getLog().debug(string); break;
        case LogChute.DEBUG_ID: mojo.getLog().debug(string); break;
        case LogChute.INFO_ID: mojo.getLog().info(string); break;
        case LogChute.WARN_ID: mojo.getLog().warn(string); break;
        case LogChute.ERROR_ID: mojo.getLog().error(string); break;
        default: mojo.getLog().debug(string);
    }
}
 
Example #23
Source File: StringExpander.java    From jsqsh with Apache License 2.0 5 votes vote down vote up
private String logPrefix(int level) {
    
    switch (level) {
        
        case LogChute.TRACE_ID: return "TRACE";
        case LogChute.DEBUG_ID: return "DEBUG";
        case LogChute.INFO_ID: return "INOF";
        case LogChute.WARN_ID: return "WARN";
        case LogChute.ERROR_ID: return "ERROR";
        default:
            return "UNKNOWN";
    }
}
 
Example #24
Source File: StringExpander.java    From jsqsh with Apache License 2.0 5 votes vote down vote up
/**
 * Used to log a message.
 */
@Override
public void log (int level, String message) {

    if (level >= LogChute.WARN_ID) {
        
        System.err.println(logPrefix(level)
            + ": Failed while performing variable expansion processing: "
            + message);
    }
}
 
Example #25
Source File: ExtensionManager.java    From jsqsh with Apache License 2.0 5 votes vote down vote up
/**
 * Used to log a message.
 */
@Override
public void log (int level, String message) {

    if (level >= LogChute.WARN_ID) {
        
        System.err.println(logPrefix(level)
            + ": Failed while performing variable expansion processing: "
            + message);
    }
}
 
Example #26
Source File: StringExpander.java    From jsqsh with Apache License 2.0 2 votes vote down vote up
/**
 * Used by LogChute to determine if a logging level is current
 * enabled.
 * 
 * @param level The level we are testing.
 */
@Override
public boolean isLevelEnabled (int level) {
    
    return (level >= LogChute.WARN_ID);
}
 
Example #27
Source File: ExtensionManager.java    From jsqsh with Apache License 2.0 2 votes vote down vote up
/**
 * Used by LogChute to determine if a logging level is current
 * enabled.
 * 
 * @param level The level we are testing.
 */
@Override
public boolean isLevelEnabled (int level) {
    
    return (level >= LogChute.WARN_ID);
}
 
Example #28
Source File: CustomTitle.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Tell the runtime system to just log warnings and errors
 *
 * @param level the level to check if it is enabled
 * @return      true, for warning and error levels, false otherwise
 */
@Override
public boolean isLevelEnabled (int level) {
	return (level == LogChute.WARN_ID) || (level == LogChute.ERROR_ID);
}