2 * Copyright (c) 2018-2019. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess;
19 import java.time.LocalDateTime;
20 import java.time.format.DateTimeFormatter;
21 import java.util.Calendar;
26 * @author Dmitry Samoshin aka gotty
28 public class ChessHogConsole {
30 private static final String EMPTY = "";
31 private static final String SPACE = " ";
33 private static final String[] ASCII_LOGO = {
35 " | | _|_ _| |___ ___ ___ ___ _| |___ ",
36 " | | -_| . | . | -_| _| . | . | -_| ",
37 " | |___|___|_ |___|___|___|___|___| ",
38 " |___|___| |___| _ _ ",
39 " ___| |_ ___ ___ ___| |_ ___ ___ ",
40 " | _| | -_|_ -|_ -| | . | . | ",
41 " |___|_|_|___|___|___|_|_|___|_ | ",
45 private static final String COPYRIGHT = "Copyright (c) Hedgecode";
47 private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss");
48 private static final DateTimeFormatter DATETIME_FORMAT = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
50 private static boolean logMode = false;
52 private ChessHogConsole() {
55 public static void setLogMode(boolean isLogMode) {
59 public static void console(String message) {
67 public static void output(String message) {
73 public static void log(String message) {
79 public static void init() {
89 private static String logTime() {
90 return "[" + TIME_FORMAT.format(LocalDateTime.now()) + "]" + SPACE;
93 private static void asciiLogo() {
94 for (String line : ASCII_LOGO) {
99 private static void copyright() {
100 int inceptionYear = Integer.parseInt(
101 ChessHogProperties.get("chesshog.inception.year")
103 int currentYear = Calendar.getInstance().get(Calendar.YEAR);
104 String years = currentYear > inceptionYear
105 ? inceptionYear + "-" + currentYear + SPACE
106 : inceptionYear + SPACE;
108 alignCenter(years + COPYRIGHT)
112 private static void version() {
114 alignCenter("v. " + ChessHogProperties.get("chesshog.version"))
118 private static void os() {
121 SPACE + System.getProperty("os.name") +
122 SPACE + System.getProperty("os.version") +
123 SPACE + System.getProperty("os.arch")
127 private static void jave() {
130 SPACE + System.getProperty("java.runtime.name") +
131 SPACE + System.getProperty("java.runtime.version")
135 SPACE + System.getProperty("java.vm.vendor") +
136 SPACE + System.getProperty("java.vm.name") +
137 SPACE + System.getProperty("java.vm.version")
141 private static String alignCenter(String message) {
142 int indent = (ASCII_LOGO[0].length() + message.length()) / 2;
143 return String.format("%" + indent + "s", message);