@@ -40,7 +40,27 @@ static StartupLogger()
40
40
}
41
41
}
42
42
43
- public static void Log ( string message , params object ? [ ] args )
43
+ public static void Log ( string message )
44
+ {
45
+ LogCore ( message , null ) ;
46
+ }
47
+
48
+ public static void Log ( string message , object ? arg0 )
49
+ {
50
+ LogCore ( message , [ arg0 ] ) ;
51
+ }
52
+
53
+ public static void Log ( string message , object ? arg0 , object ? arg1 )
54
+ {
55
+ LogCore ( message , [ arg0 , arg1 ] ) ;
56
+ }
57
+
58
+ public static void Log ( string message , object ? arg0 , object ? arg1 , object ? arg2 )
59
+ {
60
+ LogCore ( message , [ arg0 , arg1 , arg2 ] ) ;
61
+ }
62
+
63
+ private static void LogCore ( string message , object ? [ ] ? args )
44
64
{
45
65
if ( StartupLogFilePath == null )
46
66
{
@@ -52,6 +72,7 @@ public static void Log(string message, params object?[] args)
52
72
lock ( PadLock )
53
73
{
54
74
using var fileSink = new FileSink ( StartupLogFilePath ) ;
75
+
55
76
if ( DebugEnabled )
56
77
{
57
78
var currentDomain = AppDomain . CurrentDomain ;
@@ -72,14 +93,40 @@ public static void Log(string message, params object?[] args)
72
93
73
94
public static void Log ( Exception ex , string message , params object ? [ ] args )
74
95
{
75
- Log ( $ "{ message } { Environment . NewLine } { ex } ", args ) ;
96
+ // Format the message first, then append exception
97
+ var formattedMessage = args . Length > 0 ? string . Format ( message , args ) : message ;
98
+ Log ( "{0}{1}{2}" , formattedMessage , Environment . NewLine , ex ) ;
99
+ }
100
+
101
+ public static void Debug ( string message )
102
+ {
103
+ if ( DebugEnabled )
104
+ {
105
+ LogCore ( message , null ) ;
106
+ }
107
+ }
108
+
109
+ public static void Debug ( string message , object ? arg0 )
110
+ {
111
+ if ( DebugEnabled )
112
+ {
113
+ LogCore ( message , [ arg0 ] ) ;
114
+ }
115
+ }
116
+
117
+ public static void Debug ( string message , object ? arg0 , object ? arg1 )
118
+ {
119
+ if ( DebugEnabled )
120
+ {
121
+ LogCore ( message , [ arg0 , arg1 ] ) ;
122
+ }
76
123
}
77
124
78
- public static void Debug ( string message , params object ? [ ] args )
125
+ public static void Debug ( string message , object ? arg0 , object ? arg1 , object ? arg2 )
79
126
{
80
127
if ( DebugEnabled )
81
128
{
82
- Log ( message , args ) ;
129
+ LogCore ( message , [ arg0 , arg1 , arg2 ] ) ;
83
130
}
84
131
}
85
132
@@ -141,12 +188,14 @@ private static string ComputeStartupLogFilePath(string logDirectory)
141
188
{
142
189
// Do our best to not block other processes on write by using the process name and id
143
190
using var process = Process . GetCurrentProcess ( ) ;
144
- return Path . Combine ( logDirectory , $ "dotnet-tracer-loader-{ process . ProcessName } -{ process . Id } .log") ;
191
+ var fileName = string . Concat ( "dotnet-tracer-loader-" , process . ProcessName , "-" , process . Id . ToString ( ) , ".log" ) ;
192
+ return Path . Combine ( logDirectory , fileName ) ;
145
193
}
146
194
catch
147
195
{
148
196
// We can't get the process info, use a random guid instead
149
- return Path . Combine ( logDirectory , $ "dotnet-tracer-loader-{ Guid . NewGuid ( ) } .log") ;
197
+ var fileName = string . Concat ( "dotnet-tracer-loader-" , Guid . NewGuid ( ) . ToString ( ) , ".log" ) ;
198
+ return Path . Combine ( logDirectory , fileName ) ;
150
199
}
151
200
}
152
201
}
0 commit comments