java/sql-dk/src/info/globalcode/sql/dk/logging/LoggerInitializer.java
author František Kučera <franta-hg@frantovo.cz>
Wed, 25 Dec 2013 00:43:06 +0100
branchv_0
changeset 55 f5ed7c4efacc
child 57 a736c3917946
permissions -rw-r--r--
colorful logging
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * SQL-DK
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2013 František Kučera (frantovo.cz)
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, either version 3 of the License, or
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 * (at your option) any later version.
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 *
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 * GNU General Public License for more details.
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 *
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
 */
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
package info.globalcode.sql.dk.logging;
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
import info.globalcode.sql.dk.Constants;
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
import java.util.logging.ConsoleHandler;
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
import java.util.logging.Level;
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
import java.util.logging.Logger;
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
/**
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
 * Configures logging subsystem.
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
 * Usage: java -Djava.util.logging.config.class=info.globalcode.sql.dk.logging.LoggerInitializer …
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
 *
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
 * @author Ing. František Kučera (frantovo.cz)
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
 */
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
public class LoggerInitializer {
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	public LoggerInitializer() {
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
		Logger logger = Logger.getLogger(Constants.JAVA_PACKAGE);
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
		ConsoleHandler handler = new ConsoleHandler();
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
		ColorfulConsoleFormatter formatter = new ColorfulConsoleFormatter();
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
		logger.addHandler(handler);
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
		handler.setFormatter(formatter);
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
		handler.setLevel(Level.FINE);
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
		logger.setLevel(Level.FINE);
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
		/**
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		 * TODO: FileHandler – detailed logs in file in ~/sql-dk/log/…
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
		 */
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
	}
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
}