Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(shorebird_cli): add verbose logging to ShorebirdProcess #564

Merged
merged 9 commits into from
May 30, 2023
1 change: 1 addition & 0 deletions packages/shorebird_cli/lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ShorebirdCliCommandRunner extends CompletionCommandRunner<int> {
);
process = ShorebirdProcess(
engineConfig: engineConfig,
logger: _logger,
);

return await runCommand(topLevelResults) ?? ExitCode.success.code;
Expand Down
29 changes: 24 additions & 5 deletions packages/shorebird_cli/lib/src/shorebird_process.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:mason_logger/mason_logger.dart';
import 'package:meta/meta.dart';
import 'package:shorebird_cli/src/shorebird_environment.dart';

Expand All @@ -24,11 +25,14 @@ class EngineConfig {
class ShorebirdProcess {
ShorebirdProcess({
required this.engineConfig,
Logger? logger,
ProcessWrapper? processWrapper, // For mocking ShorebirdProcess.
}) : processWrapper = processWrapper ?? ProcessWrapper();
}) : logger = logger ?? Logger(),
processWrapper = processWrapper ?? ProcessWrapper();

final ProcessWrapper processWrapper;
final EngineConfig engineConfig;
final Logger logger;

Future<ShorebirdProcessResult> run(
String executable,
Expand All @@ -46,9 +50,17 @@ class ShorebirdProcess {
);
}

final resolvedExecutable =
useVendedFlutter ? _resolveExecutable(executable) : executable;
final resolvedArguments =
useVendedFlutter ? _resolveArguments(executable, arguments) : arguments;
logger.detail(
'''[Process.run] $resolvedExecutable ${resolvedArguments.join(' ')} ${workingDirectory == null ? '' : '(in $workingDirectory)'}''',
bryanoltman marked this conversation as resolved.
Show resolved Hide resolved
);

return processWrapper.run(
useVendedFlutter ? _resolveExecutable(executable) : executable,
useVendedFlutter ? _resolveArguments(executable, arguments) : arguments,
resolvedExecutable,
resolvedArguments,
runInShell: runInShell,
workingDirectory: workingDirectory,
environment: resolvedEnvironment,
Expand All @@ -69,10 +81,17 @@ class ShorebirdProcess {
_environmentOverrides(executable: executable),
);
}
final resolvedExecutable =
useVendedFlutter ? _resolveExecutable(executable) : executable;
final resolvedArguments =
useVendedFlutter ? _resolveArguments(executable, arguments) : arguments;
logger.detail(
'[Process.start] $resolvedExecutable ${resolvedArguments.join(' ')}',
);

return processWrapper.start(
useVendedFlutter ? _resolveExecutable(executable) : executable,
useVendedFlutter ? _resolveArguments(executable, arguments) : arguments,
resolvedExecutable,
resolvedArguments,
runInShell: runInShell,
environment: resolvedEnvironment,
);
Expand Down