Improve logging
This commit is contained in:
Родитель
37b821cbe0
Коммит
3eaca53833
10
README.md
10
README.md
|
@ -46,6 +46,16 @@ It can take a while to refresh the Gradle tasks, so you should permanently ignor
|
|||
]
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
View the Gradle Tasks refresh process output and errors by selecting "Gradle Tasks" in the output panel:
|
||||
|
||||
<img src="./images/output.png" width="600" />
|
||||
|
||||
Gradle Task output and errors will be shown in Terminal panel after you've run a task:
|
||||
|
||||
<img src="./images/terminal.png" width="600" />
|
||||
|
||||
## Credits
|
||||
|
||||
- Originally forked from [Cazzar/vscode-gradle](https://github.com/Cazzar/vscode-gradle)
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 115 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 139 KiB |
|
@ -25,19 +25,26 @@ public class CliApp {
|
|||
private File sourceDir;
|
||||
private File targetFile;
|
||||
private Logger logger;
|
||||
private StreamHandler handler;
|
||||
private ProgressListener progressListener;
|
||||
|
||||
public CliApp(File sourceDir, File targetFile) {
|
||||
this.sourceDir = sourceDir;
|
||||
this.targetFile = targetFile;
|
||||
|
||||
this.handler = new ConsoleHandler();
|
||||
this.handler.setFormatter(new BasicWriteFormatter());
|
||||
this.handler.setLevel(Level.ALL);
|
||||
StreamHandler handler = new ConsoleHandler();
|
||||
handler.setFormatter(new BasicWriteFormatter());
|
||||
handler.setLevel(Level.ALL);
|
||||
|
||||
this.logger = Logger.getLogger("CliApp");
|
||||
this.logger.setUseParentHandlers(false);
|
||||
this.logger.addHandler(handler);
|
||||
|
||||
this.progressListener = new ProgressListener() {
|
||||
@Override
|
||||
public void statusChanged(ProgressEvent progressEvent) {
|
||||
logger.info(".");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class BasicWriteFormatter extends Formatter {
|
||||
|
@ -69,6 +76,9 @@ public class CliApp {
|
|||
byte[] strToBytes = jsonString.getBytes();
|
||||
outputStream.write(strToBytes);
|
||||
}
|
||||
String lineSep = System.lineSeparator();
|
||||
String absolutePath = targetFile.getAbsolutePath();
|
||||
logger.info(String.format("%sSuccessfully written: %s%s", lineSep, absolutePath, lineSep));
|
||||
}
|
||||
|
||||
private JsonArray getProjects() throws CliAppException {
|
||||
|
@ -77,13 +87,6 @@ public class CliApp {
|
|||
GradleBuild rootBuild;
|
||||
GradleProject rootProject;
|
||||
|
||||
ProgressListener progressListener = new ProgressListener() {
|
||||
@Override
|
||||
public void statusChanged(ProgressEvent progressEvent) {
|
||||
logger.info(".");
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
connection = GradleConnector.newConnector().forProjectDirectory(sourceDir).connect();
|
||||
ModelBuilder<GradleBuild> rootBuilder = connection.model(GradleBuild.class);
|
||||
|
|
|
@ -320,7 +320,7 @@ function debugCommand(
|
|||
args: ReadonlyArray<string>,
|
||||
outputChannel: vscode.OutputChannel
|
||||
): void {
|
||||
const message = `Executing: ${command} ${args.join(' ')}`;
|
||||
const message = `${command} ${args.join(' ')}`;
|
||||
outputChannel.appendLine(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,9 @@ describe(fixtureName, () => {
|
|||
const outputChannel = extension!.exports.outputChannel;
|
||||
sinon.replace(outputChannel, 'appendLine', sinon.fake());
|
||||
await vscode.commands.executeCommand('gradle.refresh');
|
||||
assert.ok(outputChannel.appendLine.calledWith(sinon.match(/Executing/)));
|
||||
assert.ok(
|
||||
outputChannel.appendLine.calledWith(sinon.match(/gradle-tasks/))
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче