annotate src/goodjava/logger/Level.java @ 1448:6fc083e1d08c

start logger
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Feb 2020 18:14:32 -0700
parents
children dd14d2dce7ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1448
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.logger;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 final class Level {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 public final static int DEBUG = 0;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 public final static int INFO = 1;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 public final static int WARN = 2;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 public final static int ERROR = 3;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 public final static int OFF = 4;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 private static final String[] names = {"DEBUG","INFO","WARN","ERROR"};
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 public static String toString(int level) {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 return names[level];
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 }
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 private static final String[] paddedNames = {"DEBUG","INFO ","WARN ","ERROR"};
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 public static String toPaddedString(int level) {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 return paddedNames[level];
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 }
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 }