Skip to content

Commit 9e2d46a

Browse files
committed
fix(mcl.utils.process): Improve logging
1 parent bbaee5f commit 9e2d46a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/mcl/src/src/mcl/utils/process.d

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import std.json : JSONValue, parseJSON;
77

88
bool isRoot() => geteuid() == 0;
99

10+
string bold(string s) => "\033[1m" ~ s ~ "\033[0m";
11+
1012
T execute(T = string)(string args, bool printCommand = true, bool returnErr = false) if (is(T == string) || is(T == ProcessPipes) || is(T == JSONValue))
1113
{
1214
return execute!T(args.split(" "), printCommand, returnErr);
@@ -16,7 +18,7 @@ T execute(T = string)(string[] args, bool printCommand = true, bool returnErr =
1618
import std.exception : enforce;
1719
import std.format : format;
1820
import std.process : pipeShell, wait, Redirect, escapeShellCommand;
19-
import std.logger : logf, LogLevel;
21+
import std.logger : infof, logf, LogLevel;
2022
import std.array : join;
2123
import std.algorithm : map;
2224
import std.conv : to;
@@ -40,6 +42,14 @@ T execute(T = string)(string[] args, bool printCommand = true, bool returnErr =
4042

4143
int status = wait(res.pid);
4244
// enforce(status == 0, "Command `%s` failed with status %s, stderr: \n%s".format(args, status, stderr));
45+
46+
infof("
47+
---
48+
$ `%s`
49+
stdout: `%s`
50+
stderr: `%s`
51+
---", cmd.bold, stdout.bold, stderr.bold);
52+
4353
if (returnErr)
4454
{
4555
output = stderr;

0 commit comments

Comments
 (0)