Skip to content

Commit 47d64c2

Browse files
author
Marc-Henry GEAY
committed
Comment almost majority of files. Prepare database storage. Reorganize levels and implement TRACE level.
1 parent e36c061 commit 47d64c2

15 files changed

Lines changed: 102 additions & 35 deletions

src/project/architecture/javaLogger/modules/config/ConfigFromProperties.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public void setConfig() {
3636
if(!configProp.isEmpty()) {
3737
for(String key : configProp.stringPropertyNames()) {
3838
String value = configProp.getProperty(key);
39-
//System.out.println(key + " => " + value);
4039
config.put(key, value);
4140
}
4241
}

src/project/architecture/javaLogger/modules/config/Configurator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import java.util.Map;
44

5+
/**
6+
* Interface of Config module
7+
* @author kadary
8+
* @version 1.0
9+
*/
510
public interface Configurator {
611

712
public abstract void setConfig();

src/project/architecture/javaLogger/modules/core/AbstractLevel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package project.architecture.javaLogger.modules.core;
22

3+
/**
4+
* @author kadary
5+
* @version 1.0
6+
*/
37
public class AbstractLevel {
48

59
protected String name;

src/project/architecture/javaLogger/modules/core/AbstractLogger.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* @author kadary
12-
*
12+
* @version 1.0
1313
*/
1414
public class AbstractLogger implements Logger {
1515

@@ -117,4 +117,25 @@ public void debug(String message) {
117117
db.log(Level.DEBUG, message, this.getFQCN(), Target.DB);
118118
}
119119
}
120+
121+
@Override
122+
public boolean isTraceEnabled() {
123+
return isEnabled(Level.TRACE.getName());
124+
}
125+
126+
@Override
127+
public void trace(String message) {
128+
if (isEnabled(Target.CONSOLE.name())) {
129+
console.log(Level.TRACE, message, this.getFQCN(), Target.CONSOLE);
130+
}
131+
132+
if (isEnabled(Target.FILE.name())) {
133+
file.log(Level.TRACE, message, this.getFQCN(), Target.FILE);
134+
}
135+
136+
if (isEnabled(Target.DB.name())) {
137+
db.log(Level.TRACE, message, this.getFQCN(), Target.DB);
138+
}
139+
140+
}
120141
}

src/project/architecture/javaLogger/modules/core/ExtendedLogger.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33

44
/**
5+
* ???
56
* @author kadary
6-
*
7+
* version 1.0
78
*/
89
public class ExtendedLogger extends AbstractLogger {
910

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
package project.architecture.javaLogger.modules.core;
22

3-
43
/**
4+
* Herited class with our 6 log levels : TRACE > DEBUG > INFO > WARM > ERROR > OFF
5+
* off - Logger disabled
6+
* error - Other runtime errors or unexpected conditions. Expect these to be immediately visible on a status console.
7+
* warn - Use of deprecated APIs, poor use of API, 'almost' errors, other runtime situations that are undesirable or unexpected, but not necessarily "wrong". Expect these to be immediately visible on a status console.
8+
* info - Interesting runtime events (startup/shutdown). Expect these to be immediately visible on a console, so be conservative and keep to a minimum.
9+
* debug - detailed information on the flow through the system. Expect these to be written to logs only.
10+
* trace - more detailed information. Expect these to be written to logs only.
11+
*
512
* @author kadary
6-
*
13+
* @version 1.1
714
*/
815
public class Level extends AbstractLevel {
916

@@ -12,17 +19,18 @@ public Level(String name, int value) {
1219
this.setValue(value);
1320
}
1421

15-
public static final Level OFF = new Level("OFF", Integer.MIN_VALUE);
22+
public static final Level TRACE = new Level("TRACE", Integer.MAX_VALUE);
1623

24+
public static final Level DEBUG = new Level("DEBUG", 400);
1725

18-
public static final Level INFO = new Level("INFO", 500);
26+
public static final Level INFO = new Level("INFO", 300);
1927

20-
public static final Level WARN = new Level("WARN", 1000);
28+
public static final Level WARN = new Level("WARN", 200);
2129

22-
public static final Level DEBUG = new Level("DEBUG", 1500);
30+
public static final Level ERROR = new Level("ERROR", 100);
31+
32+
public static final Level OFF = new Level("OFF", Integer.MIN_VALUE);
2333

24-
public static final Level ERROR = new Level("ERROR", 2000);
2534

26-
public static final Level ALL = new Level("ALL", Integer.MAX_VALUE);
2735

2836
}

src/project/architecture/javaLogger/modules/core/LogManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import project.architecture.javaLogger.modules.config.ConfigFromProperties;
77
import project.architecture.javaLogger.modules.config.Configurator;
88

9-
109
/**
10+
* Principal class of Logger. it's must be imported in project by customer
1111
* @author kadary
12-
*
12+
* @version 1.0
1313
*/
1414
public class LogManager {
1515

@@ -27,6 +27,11 @@ public LogManager() {
2727
fqcn = Thread. currentThread().getStackTrace()[2].getClassName();
2828
}
2929

30+
/**
31+
* Return string log
32+
* @param name [Fully-Qualified Class Name]
33+
* @return Full log : Date+Time FQCN Level Log message
34+
*/
3035
public Logger getLogger(String name) {
3136
if (name != null && name != "") {
3237
this.fqcn = name;

src/project/architecture/javaLogger/modules/core/Logger.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,33 @@
33

44

55
/**
6-
* @author kadary
7-
*
6+
* Implementation of Log msg types and FQCN path
7+
* @author kadary, mhgeay
8+
* @version 1.1
89
*/
910
public interface Logger {
1011

12+
// TRACE
13+
boolean isTraceEnabled();
14+
void trace(String message);
15+
16+
// DEBUG
17+
boolean isDebugEnabled();
18+
void debug(String message);
19+
20+
// INFO
1121
boolean isInfoEnabled();
1222
void info(String message);
1323

24+
// WARNING
1425
boolean isWarnEnabled();
1526
void warn(String message);
1627

28+
// ERROR
1729
boolean isErrorEnabled();
1830
void error(String message);
19-
20-
boolean isDebugEnabled();
21-
void debug(String message);
2231

32+
// Custom path (FQCN)
2333
String getFQCN();
2434
void setFQCN(String fqcn);
2535
}

src/project/architecture/javaLogger/modules/output/AbstractHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/**
77
* @author kadary
8-
*
8+
* @version 1.0
99
*/
1010
public abstract class AbstractHandler implements Handler {
1111

src/project/architecture/javaLogger/modules/output/ConsoleHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
import project.architecture.javaLogger.modules.core.Level;
99

1010
/**
11-
* @author Adeline, kadary
12-
*
11+
* Output log through console
12+
* @author adepolas, kadary
13+
* @version 1.0
1314
*/
1415
public class ConsoleHandler extends AbstractHandler {
1516
@Override

0 commit comments

Comments
 (0)