Java Code Examples for org.apache.log4j.Level#toInt()

The following examples show how to use org.apache.log4j.Level#toInt() . 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: EclipseLogAppender.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private int mapLevel(Level level) {
	switch (level.toInt()) {
	case Priority.DEBUG_INT:
	case Priority.INFO_INT:
		return IStatus.INFO;

	case Priority.WARN_INT:
		return IStatus.WARNING;

	case Priority.ERROR_INT:
	case Priority.FATAL_INT:
		return IStatus.ERROR;

	default:
		return IStatus.INFO;
	}
}
 
Example 2
Source File: EclipseLogAppender.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private int mapLevel(Level level) {
	switch (level.toInt()) {
		case Priority.DEBUG_INT:
		case Priority.INFO_INT:
			return IStatus.INFO;

		case Priority.WARN_INT:
			return IStatus.WARNING;

		case Priority.ERROR_INT:
		case Priority.FATAL_INT:
			return IStatus.ERROR;

		default:
			return IStatus.INFO;
	}
}
 
Example 3
Source File: LogManager.java    From pegasus with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the debug level. All those messages are logged which have a level less than equal to the
 * debug level.
 *
 * @param level the level to which the debug level needs to be set to.
 */
public void setLevel(Level level) {
    int value = level.toInt();
    switch (value) {
        case Level.DEBUG_INT:
            value = LogManager.DEBUG_MESSAGE_LEVEL;
            break;

        case Level.INFO_INT:
            value = LogManager.INFO_MESSAGE_LEVEL;
            break;

        case Level.WARN_INT:
            value = LogManager.WARNING_MESSAGE_LEVEL;
            break;

        case Level.ERROR_INT:
            value = LogManager.ERROR_MESSAGE_LEVEL;
            break;

        default:
            value = LogManager.FATAL_MESSAGE_LEVEL;
            break;
    }
    setLevel(value, false);
}
 
Example 4
Source File: Default.java    From pegasus with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the debug level. All those messages are logged which have a level less than equal to the
 * debug level.
 *
 * @param level the level to which the debug level needs to be set to.
 */
public void setLevel(Level level) {
    int value = level.toInt();
    switch (value) {
        case Level.DEBUG_INT:
            value = Default.DEBUG_MESSAGE_LEVEL;
            break;

        case Level.INFO_INT:
            value = Default.INFO_MESSAGE_LEVEL;
            break;

        case Level.WARN_INT:
            value = Default.WARNING_MESSAGE_LEVEL;
            break;

        case Level.ERROR_INT:
            value = Default.ERROR_MESSAGE_LEVEL;
            break;

        default:
            value = Default.FATAL_MESSAGE_LEVEL;
            break;
    }
    setLevel(value, false);
}
 
Example 5
Source File: LogWriter.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param logger the logger this Writer should write to
 * @param level the debug level to write to the logger with
 */
public LogWriter(final Logger logger, final Level level) {
  Preconditions.checkNotNull(logger);
  Preconditions.checkArgument((level == Level.DEBUG) || (level == Level.ERROR) ||
      (level == Level.INFO) || (level == Level.TRACE) || (level == Level.WARN),
      "level must be a logging level");

  this.logger = logger;
  this.level = level.toInt();
  stringBuilder = new StringBuilder(80);
  isClosed = false;
}
 
Example 6
Source File: Log4jLogEvent.java    From xian with Apache License 2.0 5 votes vote down vote up
private int levelToSyslogLevel(final Level level) {
    if (level.toInt() <= Level.DEBUG.toInt()) {
        return GelfMessage.DEFAUL_LEVEL;
    }

    if (level.toInt() <= Level.INFO.toInt()) {
        return 6;
    }

    if (level.toInt() <= Level.WARN.toInt()) {
        return 4;
    }

    if (level.toInt() <= Level.ERROR.toInt()) {
        return 3;
    }

    if (level.toInt() <= Level.FATAL.toInt()) {
        return 2;
    }

    if (level.toInt() > Level.FATAL.toInt()) {
        return 0;
    }

    return GelfMessage.DEFAUL_LEVEL;
}
 
Example 7
Source File: AbstractHTree.java    From database with GNU General Public License v2.0 5 votes vote down vote up
public boolean dump(final Level level, final PrintStream out,
			final boolean materialize) {

        // True iff we will write out the node structure.
        final boolean info = level.toInt() <= Level.INFO.toInt();

//        final IBTreeUtilizationReport utils = getUtilization();

        if (info) {

			out.print("addressBits=" + addressBits);
			out.print(", (2^addressBits)=" + (1 << addressBits));
			out.print(", #nodes=" + getNodeCount());
			out.print(", #leaves=" + getLeafCount());
			out.print(", #entries=" + getEntryCount());
			out.println();
//                    + ", nodeUtil="
//                    + utils.getNodeUtilization() + "%, leafUtil="
//                    + utils.getLeafUtilization() + "%, utilization="
//                    + utils.getTotalUtilization() + "%"
        }

        if (root != null) {

            return root.dump(level, out, 0, true, materialize);

        } else
            return true;

    }
 
Example 8
Source File: BucketPage.java    From database with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected boolean dump(final Level level, final PrintStream out,
		final int height, final boolean recursive, final boolean materialize) {

	final boolean debug = level.toInt() <= Level.DEBUG.toInt();

	// Set to false iff an inconsistency is detected.
	boolean ok = true;

	if (parent == null || parent.get() == null) {
		out.println(indent(height) + "ERROR: parent not set");
		ok = false;
	}

	if (globalDepth > parent.get().globalDepth) {
		out.println(indent(height)
				+ "ERROR: localDepth exceeds globalDepth of parent");
		ok = false;
	}

	/*
	 * TODO Count the #of pointers in each buddy hash table of the parent
	 * to each buddy bucket in this bucket page and verify that the
	 * globalDepth on the child is consistent with the pointers in the
	 * parent.
	 * 
	 * TODO The same check must be performed for the directory page to
	 * cross validate the parent child linking pattern with the transient
	 * cached globalDepth fields.
	 */

	if (debug || !ok) {

		out.println(indent(height) + toString());

	}

	return ok;

}
 
Example 9
Source File: EclipseLogAppender.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isDoLog(Level level) {
	return level.toInt() >= Priority.WARN_INT;
}
 
Example 10
Source File: EclipseLogAppender.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private boolean isDoLog(Level level) {
	return level.toInt() >= Priority.WARN_INT;
}
 
Example 11
Source File: AOSynchronization.java    From scheduling with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("squid:S3776")
private void logWithContext(TaskId taskId, String channel, String message, Throwable exception, Level level)
        throws InvalidChannelException {
    String channelHeader = "[" + Synchronization.class.getSimpleName() + "]" +
                           (channel != null ? "[" + Channel.class.getSimpleName() + "=" + channel + "] " : "");
    switch (level.toInt()) {
        case Level.TRACE_INT:
            if (logger.isTraceEnabled()) {
                TaskLogger.getInstance().info(taskId, channelHeader + message);
            }
            break;
        case Level.DEBUG_INT:
            if (logger.isDebugEnabled()) {
                TaskLogger.getInstance().info(taskId, channelHeader + message);
            }
            break;
        case Level.INFO_INT:
            if (logger.isInfoEnabled()) {
                TaskLogger.getInstance().info(taskId, channelHeader + message);
            }
            break;
        case Level.WARN_INT:
            if (exception != null) {
                TaskLogger.getInstance().warn(taskId, channelHeader + message, exception);
            } else {
                TaskLogger.getInstance().warn(taskId, channelHeader + message);
            }
            break;
        case Level.ERROR_INT:
            if (exception != null) {
                TaskLogger.getInstance().error(taskId, channelHeader + message, exception);
            } else {
                TaskLogger.getInstance().error(taskId, channelHeader + message);
            }
            break;
        default:
            // no action
    }
    if (logger.isTraceEnabled() && channel != null) {
        TaskLogger.getInstance().info(taskId, channelHeader + "New channel content : " + getChannel(channel));
    }
}
 
Example 12
Source File: AbstractBTree.java    From database with GNU General Public License v2.0 3 votes vote down vote up
public boolean dump(final Level level, final PrintStream out) {

        // True iff we will write out the node structure.
        final boolean info = level.toInt() <= Level.INFO.toInt();

        final IBTreeUtilizationReport utils = getUtilization();

        if (info) {

        	final int branchingFactor = getBranchingFactor();

            final int height = getHeight();

            final long nnodes = getNodeCount();

            final long nleaves = getLeafCount();

            final long nentries = getEntryCount();

			out.println("branchingFactor=" + branchingFactor + ", height="
					+ height + ", #nodes=" + nnodes + ", #leaves=" + nleaves
					+ ", #entries=" + nentries + ", nodeUtil="
					+ utils.getNodeUtilization() + "%, leafUtil="
					+ utils.getLeafUtilization() + "%, utilization="
					+ utils.getTotalUtilization() + "%");
        }

        if (root != null) {

            return root.dump(level, out, 0, true);

        } else
            return true;

    }
 
Example 13
Source File: Log4j.java    From pegasus with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the debug level. All those messages are logged which have a level less than equal to the
 * debug level. In case the boolean info is set, all the info messages are also logged.
 *
 * @param level the level to which the debug level needs to be set to.
 * @param info boolean denoting whether the INFO messages need to be logged or not.
 */
protected void setLevel(Level level, boolean info) {
    mDebugLevel = level.toInt();
    mLogger.setLevel(level);
}