Skip to content

Commit a5ddc60

Browse files
Artem LabazinArtem Labazin
authored andcommitted
Reorganized code
1 parent 92e1689 commit a5ddc60

22 files changed

+316
-292
lines changed

.codestyle/checkstyle.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ limitations under the License.
7171

7272
<!-- Checks for Javadoc comments. -->
7373
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
74-
<!-- <module name="JavadocMethod">
74+
<module name="JavadocMethod">
7575
<property name="scope" value="protected"/>
7676
<property name="allowedAnnotations" value="Override, Test"/>
7777
<property name="allowThrowsTagsForSubclasses" value="true"/>
@@ -98,7 +98,7 @@ limitations under the License.
9898
<property name="tagOrder" value="@param, @return, @throws, @see, @since, @author, @version, @deprecated"/>
9999
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
100100
</module>
101-
<module name="NonEmptyAtclauseDescription"/> -->
101+
<module name="NonEmptyAtclauseDescription"/>
102102

103103

104104
<!-- Checks for Naming Conventions. -->

.images/example.png

20 KB
Loading

.images/override_example.png

17.4 KB
Loading

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
- Add different logging frameworks.
1313

14+
## [1.1.0](https://github.com/appulse-projects/logging-java/releases/tag/1.1.0) - 2018-06-05
15+
16+
Reorganized code.
17+
18+
### Added
19+
20+
- JavaDoc comments.
21+
- Default `logback.xml` configuration (just includes `default.xml` config).
22+
23+
### Removed
24+
25+
- `AnsiBackground`.
26+
- `LogbackConfigurator`.
27+
- `AnsiOutputEnabledValue`.
28+
1429
## [1.0.2](https://github.com/appulse-projects/logging-java/releases/tag/1.0.2) - 2018-03-15
1530

1631
Small refactoring

README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Just add dependency to your project.
1717
<dependency>
1818
<groupId>io.appulse</groupId>
1919
<artifactId>logging-java</artifactId>
20-
<version>1.0.2</version>
20+
<version>1.1.0</version>
2121
</dependency>
2222
...
2323
</dependencies>
@@ -26,9 +26,68 @@ Just add dependency to your project.
2626
**Gradle**:
2727

2828
```groovy
29-
compile 'io.appulse:logging-java:1.0.2'
29+
compile 'io.appulse:logging-java:1.1.0'
3030
```
3131

32+
And use it as usual:
33+
34+
```java
35+
import org.slf4j.Logger;
36+
import org.slf4j.LoggerFactory;
37+
38+
public class SomeClass {
39+
40+
Logger log = LoggerFactory.getLogger(SomeClass.class);
41+
42+
public void doSomeLog () {
43+
log.info("info message");
44+
log.warn("warn message");
45+
log.error("error message");
46+
}
47+
}
48+
```
49+
50+
or, if you use a Lombok Project:
51+
52+
```java
53+
import lombok.extern.slf4j.Slf4j;
54+
55+
@Slf4j
56+
public class SomeClass {
57+
58+
public void doSomeLog () {
59+
log.info("info message");
60+
log.warn("warn message");
61+
log.error("error message");
62+
}
63+
}
64+
```
65+
66+
With default configuration (no `logback.xml` in classpath at all) it looks like:
67+
68+
![override example](https://github.com/appulse-projects/logging-java/blob/master/.images/override_example.png?raw=true)
69+
70+
You also could to override default `logback`'s configuration, like an example below.
71+
72+
**resources/logback.xml**:
73+
74+
```xml
75+
<?xml version="1.0" encoding="UTF-8"?>
76+
77+
<configuration>
78+
<property
79+
name="CONSOLE_LOG_PATTERN"
80+
value="${CONSOLE_LOG_PATTERN:-%clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([%25.25thread]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"
81+
/>
82+
83+
<include resource="io/appulse/logging/logback/base.xml"/>
84+
</configuration>
85+
```
86+
87+
And output will be like:
88+
89+
![override example](https://github.com/appulse-projects/logging-java/blob/master/.images/override_example.png?raw=true)
90+
3291
## Development
3392

3493
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License.
2424

2525
<groupId>io.appulse</groupId>
2626
<artifactId>logging-java</artifactId>
27-
<version>1.0.2</version>
27+
<version>1.1.0</version>
2828
<packaging>jar</packaging>
2929

3030
<properties>
@@ -62,7 +62,7 @@ limitations under the License.
6262
<url>https://github.com/appulse-projects/logging-java</url>
6363
<connection>scm:git:https://github.com/appulse-projects/logging-java.git</connection>
6464
<developerConnection>scm:git:https://github.com/appulse-projects/logging-java.git</developerConnection>
65-
<tag>1.0.2</tag>
65+
<tag>1.1.0</tag>
6666
</scm>
6767

6868
<distributionManagement>
@@ -98,7 +98,7 @@ limitations under the License.
9898
<dependency>
9999
<groupId>org.projectlombok</groupId>
100100
<artifactId>lombok</artifactId>
101-
<version>1.16.20</version>
101+
<version>1.18.0</version>
102102
<scope>provided</scope>
103103
</dependency>
104104

@@ -130,7 +130,7 @@ limitations under the License.
130130
<dependency>
131131
<groupId>org.assertj</groupId>
132132
<artifactId>assertj-core</artifactId>
133-
<version>3.9.1</version>
133+
<version>3.10.0</version>
134134
<scope>test</scope>
135135
</dependency>
136136
</dependencies>
@@ -273,7 +273,7 @@ limitations under the License.
273273
<dependency>
274274
<groupId>com.puppycrawl.tools</groupId>
275275
<artifactId>checkstyle</artifactId>
276-
<version>8.8</version>
276+
<version>8.10.1</version>
277277
</dependency>
278278
</dependencies>
279279
<executions>

src/main/java/io/appulse/logging/AnsiBackground.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/main/java/io/appulse/logging/AnsiColor.java

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,112 @@
1616

1717
package io.appulse.logging;
1818

19+
import static lombok.AccessLevel.PRIVATE;
20+
21+
import lombok.experimental.FieldDefaults;
22+
1923
/**
2024
* {@link AnsiElement Ansi} colors.
2125
*
2226
* @author Artem Labazin
2327
* @since 1.0.0
2428
*/
29+
@FieldDefaults(level = PRIVATE, makeFinal = true)
2530
public enum AnsiColor implements AnsiElement {
2631

32+
/**
33+
* System default ANSI color.
34+
*/
2735
DEFAULT("39"),
36+
37+
/**
38+
* Black ANSI color.
39+
*/
2840
BLACK("30"),
41+
42+
/**
43+
* Red ANSI color.
44+
*/
2945
RED("31"),
46+
47+
/**
48+
* Green ANSI color.
49+
*/
3050
GREEN("32"),
51+
52+
/**
53+
* Yellow ANSI color.
54+
*/
3155
YELLOW("33"),
56+
57+
/**
58+
* Blue ANSI color.
59+
*/
3260
BLUE("34"),
61+
62+
/**
63+
* Magenta ANSI color.
64+
*/
3365
MAGENTA("35"),
66+
67+
/**
68+
* Cyan ANSI color.
69+
*/
3470
CYAN("36"),
71+
72+
/**
73+
* White ANSI color.
74+
*/
3575
WHITE("37"),
76+
77+
/**
78+
* High bntensty black ANSI color.
79+
*/
3680
BRIGHT_BLACK("90"),
81+
82+
/**
83+
* High bntensty red ANSI color.
84+
*/
3785
BRIGHT_RED("91"),
86+
87+
/**
88+
* High bntensty green ANSI color.
89+
*/
3890
BRIGHT_GREEN("92"),
91+
92+
/**
93+
* High bntensty yellow ANSI color.
94+
*/
3995
BRIGHT_YELLOW("93"),
96+
97+
/**
98+
* High bntensty blue ANSI color.
99+
*/
40100
BRIGHT_BLUE("94"),
101+
102+
/**
103+
* High bntensty magenta ANSI color.
104+
*/
41105
BRIGHT_MAGENTA("95"),
106+
107+
/**
108+
* High bntensty cyan ANSI color.
109+
*/
42110
BRIGHT_CYAN("96"),
111+
112+
/**
113+
* High bntensty white ANSI color.
114+
*/
43115
BRIGHT_WHITE("97");
44116

45-
private final String code;
117+
String code;
46118

47119
AnsiColor (String code) {
48120
this.code = code;
49121
}
50122

51123
@Override
52124
public String toString () {
53-
return this.code;
125+
return code;
54126
}
55127
}

src/main/java/io/appulse/logging/AnsiColors.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
/**
4646
* Utility for working with {@link AnsiColor} in the context of {@link Color AWT Colors}.
4747
*
48-
* @author Artem Labazin
4948
* @since 1.0.0
49+
* @author Artem Labazin
5050
*/
51-
public final class AnsiColors {
51+
final class AnsiColors {
5252

5353
private static final Map<AnsiColor, LabColor> ANSI_COLOR_MAP;
5454

@@ -75,7 +75,7 @@ public final class AnsiColors {
7575
private AnsiColors () {
7676
}
7777

78-
public static AnsiColor getClosest (Color color) {
78+
static AnsiColor getClosest (Color color) {
7979
return getClosest(new LabColor(color));
8080
}
8181

src/main/java/io/appulse/logging/AnsiElement.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
/**
2020
* An ANSI encodable element.
2121
*
22-
* @author Artem Labazin
2322
* @since 1.0.0
23+
* @author Artem Labazin
2424
*/
2525
public interface AnsiElement {
2626

2727
/**
28+
* Overrides default {@code toString()} method for {@link AnsiElement} instances,
29+
* which should returns element's code.
30+
*
2831
* @return the ANSI escape code
2932
*/
3033
@Override

0 commit comments

Comments
 (0)