Skip to content

Commit fb50748

Browse files
committed
add: logging
1 parent 259ca16 commit fb50748

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

pom.xml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<jadler.version>1.3.1</jadler.version>
4242
<json-unit.version>1.5.3</json-unit.version>
4343
<cxf.version>4.1.0</cxf.version>
44+
<slf4j.version>1.7.10</slf4j.version>
4445
</properties>
4546

4647
<build>
@@ -156,9 +157,9 @@
156157
<version>3.2.1</version>
157158
</dependency>
158159
<dependency>
159-
<groupId>commons-logging</groupId>
160-
<artifactId>commons-logging</artifactId>
161-
<version>1.1.3</version>
160+
<groupId>org.slf4j</groupId>
161+
<artifactId>slf4j-api</artifactId>
162+
<version>${slf4j.version}</version>
162163
</dependency>
163164
<dependency>
164165
<groupId>org.apache.httpcomponents.client5</groupId>
@@ -175,6 +176,11 @@
175176
<artifactId>spring-context</artifactId>
176177
<version>${spring.version}</version>
177178
</dependency>
179+
<dependency>
180+
<groupId>org.springframework</groupId>
181+
<artifactId>spring-jcl</artifactId>
182+
<version>${spring.version}</version>
183+
</dependency>
178184
<dependency>
179185
<groupId>org.springframework</groupId>
180186
<artifactId>spring-web</artifactId>
@@ -246,7 +252,7 @@
246252
<dependency>
247253
<groupId>org.slf4j</groupId>
248254
<artifactId>slf4j-simple</artifactId>
249-
<version>1.7.10</version>
255+
<version>${slf4j.version}</version>
250256
<scope>test</scope>
251257
</dependency>
252258
<dependency>

src/main/java/cz/geek/fio/FioClient.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cz.geek.fio;
22

33
import lombok.NonNull;
4+
import lombok.extern.slf4j.Slf4j;
45
import org.apache.hc.client5.http.classic.HttpClient;
56
import org.apache.hc.client5.http.config.ConnectionConfig;
67
import org.apache.hc.client5.http.config.RequestConfig;
@@ -26,6 +27,7 @@
2627
/**
2728
* Fio Bank Client
2829
*/
30+
@Slf4j
2931
public class FioClient {
3032

3133
private static final String ROOT = "/ib_api/rest/";
@@ -70,6 +72,7 @@ public FioClient(@NonNull FioClientSettings settings) {
7072
this.restTemplate = createRestTemplate(base, settings);
7173
this.jaxb2Converter = new NamespaceIgnoringJaxb2HttpMessageConverter();
7274
this.conversionService = new FioConversionService();
75+
log.info("Fio client configured {}", base.toUriString());
7376
}
7477

7578
private RestTemplate createRestTemplate(final UriComponentsBuilder base, final FioClientSettings settings) {
@@ -113,9 +116,12 @@ private HttpClientBuilder createHttpClientBuilder(final FioClientSettings settin
113116
public FioAccountStatement getStatement(final LocalDate start, final LocalDate end) {
114117
notNull(start);
115118
notNull(end);
119+
String from = DATE_FORMATTER.format(start);
120+
String to = DATE_FORMATTER.format(end);
121+
log.info("Getting statement from {} to {}", from, to);
116122
return restTemplate.execute(STATEMENT_PERIODS, GET, null,
117123
statementExtractor(jaxb2Converter, conversionService),
118-
token, DATE_FORMATTER.format(start), DATE_FORMATTER.format(end), ExportFormat.xml);
124+
token, from, to, ExportFormat.xml);
119125
}
120126

121127
/**
@@ -130,8 +136,11 @@ public void exportStatement(final LocalDate start, final LocalDate end, final Ex
130136
notNull(start);
131137
notNull(end);
132138
notNull(format);
139+
String from = DATE_FORMATTER.format(start);
140+
String to = DATE_FORMATTER.format(end);
141+
log.info("Exporting statement {} from {} to {}", format, from, to);
133142
restTemplate.execute(STATEMENT_PERIODS, GET, null, new OutputStreamResponseExtractor(target),
134-
token, DATE_FORMATTER.format(start), DATE_FORMATTER.format(end), format);
143+
token, from, to, format);
135144
}
136145

137146
/**
@@ -142,6 +151,7 @@ public void exportStatement(final LocalDate start, final LocalDate end, final Ex
142151
* @throws FioException
143152
*/
144153
public FioAccountStatement getStatement(final int year, final int id) {
154+
log.info("Getting statement for year {} id {}", year, id);
145155
return restTemplate.execute(STATEMENT_BY_ID, GET, null,
146156
statementExtractor(jaxb2Converter, conversionService),
147157
token, year, id, ExportFormat.xml);
@@ -157,6 +167,7 @@ public FioAccountStatement getStatement(final int year, final int id) {
157167
*/
158168
public void exportStatement(final int year, final int id, final ExportFormat format, final OutputStream target) {
159169
notNull(format);
170+
log.info("Exporting statement {} for year {} id {}", format, year, id);
160171
restTemplate.execute(STATEMENT_BY_ID, GET, null, new OutputStreamResponseExtractor(target),
161172
token, year, id, format);
162173
}
@@ -167,6 +178,7 @@ public void exportStatement(final int year, final int id, final ExportFormat for
167178
* @throws FioException
168179
*/
169180
public FioAccountStatement getStatement() {
181+
log.info("Getting statement from the last download");
170182
return restTemplate.execute(STATEMENT_LAST, GET, null,
171183
statementExtractor(jaxb2Converter, conversionService),
172184
token, ExportFormat.xml);
@@ -180,6 +192,7 @@ public FioAccountStatement getStatement() {
180192
*/
181193
public void exportStatement(final ExportFormat format, final OutputStream target) {
182194
notNull(format);
195+
log.info("Exporting statement {} from the last download", format);
183196
restTemplate.execute(STATEMENT_LAST, GET, null, new OutputStreamResponseExtractor(target),
184197
token, format);
185198
}
@@ -201,6 +214,7 @@ public void setLast(final BigInteger id) {
201214
*/
202215
public void setLast(final String id) {
203216
notEmpty(id);
217+
log.info("Setting last download from {}", id);
204218
restTemplate.execute(LAST_ID, GET, null, null,
205219
token, id);
206220
}
@@ -212,8 +226,10 @@ public void setLast(final String id) {
212226
*/
213227
public void setLast(final LocalDate date) {
214228
notNull(date);
229+
String last = DATE_FORMATTER.format(date);
230+
log.info("Setting last download from {}", date);
215231
restTemplate.execute(LAST_DATE, GET, null, null,
216-
token, DATE_FORMATTER.format(date));
232+
token, last);
217233
}
218234

219235
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.slf4j.simpleLogger.defaultLogLevel = INFO

0 commit comments

Comments
 (0)