java/copy-image-resizer/src/cz/frantovo/copyImageResizer/logging/AbstractFormatter.java
author František Kučera <franta-hg@frantovo.cz>
Mon, 17 Nov 2014 21:58:52 +0100
changeset 16 4634176c6602
permissions -rw-r--r--
logging: two log formatters: ColorfulConsoleFormatter and SimpleFormatter
franta-hg@16
     1
/**
franta-hg@16
     2
 * copy-image-resizer
franta-hg@16
     3
 * Copyright © 2013 František Kučera (frantovo.cz)
franta-hg@16
     4
 *
franta-hg@16
     5
 * This program is free software: you can redistribute it and/or modify
franta-hg@16
     6
 * it under the terms of the GNU General Public License as published by
franta-hg@16
     7
 * the Free Software Foundation, either version 3 of the License, or
franta-hg@16
     8
 * (at your option) any later version.
franta-hg@16
     9
 *
franta-hg@16
    10
 * This program is distributed in the hope that it will be useful,
franta-hg@16
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@16
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@16
    13
 * GNU General Public License for more details.
franta-hg@16
    14
 *
franta-hg@16
    15
 * You should have received a copy of the GNU General Public License
franta-hg@16
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@16
    17
 */
franta-hg@16
    18
package cz.frantovo.copyImageResizer.logging;
franta-hg@16
    19
franta-hg@16
    20
import java.util.logging.Formatter;
franta-hg@16
    21
franta-hg@16
    22
/**
franta-hg@16
    23
 *
franta-hg@16
    24
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@16
    25
 */
franta-hg@16
    26
public abstract class AbstractFormatter extends Formatter {
franta-hg@16
    27
franta-hg@16
    28
	protected static String rpad(String s, int n) {
franta-hg@16
    29
		if (n > 0) {
franta-hg@16
    30
			return String.format("%1$-" + n + "s", s);
franta-hg@16
    31
		} else {
franta-hg@16
    32
			return s;
franta-hg@16
    33
		}
franta-hg@16
    34
	}
franta-hg@16
    35
franta-hg@16
    36
	private boolean printStacktrace = false;
franta-hg@16
    37
franta-hg@16
    38
	public boolean isPrintStacktrace() {
franta-hg@16
    39
		return printStacktrace;
franta-hg@16
    40
	}
franta-hg@16
    41
franta-hg@16
    42
	public void setPrintStacktrace(boolean printStacktrace) {
franta-hg@16
    43
		this.printStacktrace = printStacktrace;
franta-hg@16
    44
	}
franta-hg@16
    45
franta-hg@16
    46
}