Skip to content

Commit b449915

Browse files
authored
Merge pull request #86 from simplelocalize/more-verbose-logggin
More verbose logging
2 parents 145045b + 4b9d658 commit b449915

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

src/main/java/io/simplelocalize/cli/command/DownloadCommand.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import io.simplelocalize.cli.client.dto.DownloadRequest;
66
import io.simplelocalize.cli.client.dto.proxy.Configuration;
77
import io.simplelocalize.cli.client.dto.proxy.DownloadableFile;
8+
import io.simplelocalize.cli.util.StringUtils;
89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
1011

1112
import java.io.IOException;
13+
import java.util.ArrayList;
1214
import java.util.List;
1315

1416
public class DownloadCommand implements CliCommand
@@ -31,7 +33,7 @@ public void invoke() throws IOException, InterruptedException
3133
String languageKey = configuration.getLanguageKey();
3234
String customerId = configuration.getCustomerId();
3335
String sort = configuration.getDownloadSort();
34-
List<String> downloadOptions = configuration.getDownloadOptions();
36+
List<String> downloadOptions = new ArrayList<>(configuration.getDownloadOptions());
3537

3638
if (downloadPath.contains(TemplateKeys.NAMESPACE_TEMPLATE_KEY))
3739
{
@@ -51,6 +53,20 @@ public void invoke() throws IOException, InterruptedException
5153
.withSort(sort)
5254
.build();
5355
log.info("Preparing files to download");
56+
log.info("File format: {}", downloadFormat);
57+
if (StringUtils.isNotEmpty(customerId))
58+
{
59+
log.info("Customer ID: {}", customerId);
60+
}
61+
if (StringUtils.isNotEmpty(languageKey))
62+
{
63+
log.info("Language key: {}", languageKey);
64+
}
65+
if (StringUtils.isNotEmpty(sort))
66+
{
67+
log.info("Sort: {}", sort);
68+
}
69+
log.info("Download options: {}", downloadOptions);
5470
List<DownloadableFile> downloadableFiles = client.fetchDownloadableFiles(downloadRequest);
5571
for (DownloadableFile downloadableFile : downloadableFiles)
5672
{

src/main/java/io/simplelocalize/cli/command/UploadCommand.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.slf4j.LoggerFactory;
1313

1414
import java.io.IOException;
15+
import java.nio.file.Path;
1516
import java.util.List;
1617
import java.util.Optional;
1718

@@ -55,13 +56,25 @@ public void invoke() throws IOException, InterruptedException
5556
throw new IllegalArgumentException("Matching files could not be found", e);
5657
}
5758

59+
60+
String uploadFormat = configuration.getUploadFormat();
61+
String customerId = configuration.getCustomerId();
62+
List<String> uploadOptions = configuration.getUploadOptions();
63+
log.info("File format: {}", uploadFormat);
64+
if (StringUtils.isNotEmpty(customerId))
65+
{
66+
log.info("Customer ID: {}", customerId);
67+
}
68+
log.info("Upload options: {}", uploadOptions);
69+
5870
log.info("Found {} files to upload", filesToUpload.size());
5971
for (FileToUpload fileToUpload : filesToUpload)
6072
{
61-
long length = fileToUpload.path().toFile().length();
73+
Path path = fileToUpload.path();
74+
long length = path.toFile().length();
6275
if (length == 0)
6376
{
64-
log.warn("Skipping empty file: {}", fileToUpload.path());
77+
log.warn("Skipping empty file: {}", path);
6578
continue;
6679
}
6780

@@ -72,9 +85,10 @@ public void invoke() throws IOException, InterruptedException
7285
boolean hasConfigurationLanguageKey = StringUtils.isNotBlank(configurationLanguageKey);
7386

7487
boolean isLanguageMatching = fileLanguageKey.equals(configurationLanguageKey);
88+
String language = fileToUpload.language();
7589
if (hasFileLanguageKey && hasConfigurationLanguageKey && !isLanguageMatching)
7690
{
77-
log.info("Skipping '{}' language, file: {}", fileToUpload.language(), fileToUpload.path());
91+
log.info("Skipping '{}' language, file: {}", language, path);
7892
continue;
7993
}
8094

@@ -87,27 +101,26 @@ public void invoke() throws IOException, InterruptedException
87101
boolean isMultiLanguageFormat = isMultiLanguageFormat(configuration.getUploadFormat());
88102
if (!hasFileLanguageKey && !hasConfigurationLanguageKey && !isMultiLanguageFormat)
89103
{
90-
log.info("Language key not present in '--uploadPath' nor '--languageKey' parameter, file: {}", fileToUpload.path());
104+
log.info("Language key not present in '--uploadPath' nor '--languageKey' parameter, file: {}", path);
91105
}
92106

93-
String uploadFormat = configuration.getUploadFormat();
94-
String customerId = configuration.getCustomerId();
95-
List<String> uploadOptions = configuration.getUploadOptions();
107+
108+
String namespace = fileToUpload.namespace();
96109
UploadRequest uploadRequest = builder()
97-
.withPath(fileToUpload.path())
110+
.withPath(path)
98111
.withLanguageKey(requestLanguageKey)
99-
.withNamespace(fileToUpload.namespace())
112+
.withNamespace(namespace)
100113
.withFormat(uploadFormat)
101114
.withCustomerId(customerId)
102115
.withOptions(uploadOptions)
103116
.build();
104117

105118
if (isDryRun)
106119
{
107-
log.info("[Dry run] Found file to upload, language=[{}], namespace=[{}], file: {}", fileToUpload.language(), fileToUpload.namespace(), fileToUpload.path());
120+
log.info("[Dry run] Found file to upload, language=[{}], namespace=[{}], file: {}", language, namespace, path);
108121
} else
109122
{
110-
log.info("Uploading {}", fileToUpload.path());
123+
log.info("Uploading language=[{}] namespace=[{}] = {}", language, namespace, path);
111124
client.uploadFile(uploadRequest);
112125
}
113126
}

0 commit comments

Comments
 (0)