Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 1d13069

Browse files
committed
Allow Inspect.Vars path to be overriden with INSPECT_VARS
1 parent 2e9185a commit 1d13069

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/ServiceStack.Text/Inspect.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,24 @@ public static class Inspect
1111
{
1212
public static class Config
1313
{
14+
public const string VarsName = "vars.json";
15+
1416
public static Action<object> VarsFilter { get; set; } = DefaultVarsFilter;
1517

1618
public static void DefaultVarsFilter(object anonArgs)
1719
{
1820
try
1921
{
20-
File.WriteAllText("vars.json", anonArgs.ToSafeJson());
22+
var inspectVarsPath = Environment.GetEnvironmentVariable("INSPECT_VARS");
23+
if (inspectVarsPath == "0") // Disable
24+
return;
25+
26+
var varsPath = inspectVarsPath?.Length > 0
27+
? Path.PathSeparator == '\\'
28+
? inspectVarsPath.Replace('/','\\')
29+
: inspectVarsPath.Replace('\\','/')
30+
: VarsName;
31+
File.WriteAllText(varsPath, anonArgs.ToSafeJson());
2132
}
2233
catch (Exception ex)
2334
{

0 commit comments

Comments
 (0)