com.github.nomou.log4web.LoggerInfo Maven / Gradle / Ivy
/*
* Copyright (c) 2005, 2014 vacoor
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package com.github.nomou.log4web;
import java.util.HashMap;
import java.util.Map;
/**
* The logger information.
*
* @author vacoor
*/
public abstract class LoggerInfo implements Comparable {
/**
* ROOT logger name.
*/
public static final String ROOT_NAME = "root";
/**
* The 'name' key.
*/
public static final String NAME = "name";
/**
* The 'level' key.
*/
public static final String LEVEL = "level";
/**
* The 'set' key.
*/
public static final String SET = "set";
/**
* The name of logger.
*/
protected final String name;
/**
* Creates a logger information.
*
* @param name the name of logger
*/
protected LoggerInfo(final String name) {
this.name = name;
}
/**
* Gets the logger name.
*
* @return the name of logger
*/
public String getName() {
return this.name;
}
/**
* Gets the logger level.
*
* @return the level of logger
*/
public abstract String getLevel();
public abstract boolean isSet();
public Map getInfo() {
final Map info = new HashMap();
info.put(NAME, getName());
info.put(LEVEL, getLevel());
info.put(SET, isSet());
return info;
}
/**
* {@inheritDoc}
*/
@Override
public int compareTo(final LoggerInfo other) {
if (null == other) {
return -1;
}
if (this.equals(other)) {
return 0;
}
final String tN = getName();
final String oN = other.getName();
return ROOT_NAME.equals(tN) ? -1 : (ROOT_NAME.equals(oN) ? 1 : tN.compareTo(oN));
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
final String l = getLevel();
return '[' + (null != l ? l : "-") + "] " + name;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy