@@ -18,6 +18,28 @@ class Program
18
18
[ STAThread ]
19
19
static void Main ( string [ ] args )
20
20
{
21
+ #if DEBUG
22
+ bool waitForDebugger =
23
+ args . Any (
24
+ arg =>
25
+ string . Equals (
26
+ arg ,
27
+ "/waitForDebugger" ,
28
+ StringComparison . InvariantCultureIgnoreCase ) ) ;
29
+
30
+ // Should we wait for the debugger before starting?
31
+ if ( waitForDebugger )
32
+ {
33
+ // Wait for 25 seconds and then continue
34
+ int waitCountdown = 25 ;
35
+ while ( ! Debugger . IsAttached && waitCountdown > 0 )
36
+ {
37
+ Thread . Sleep ( 1000 ) ;
38
+ waitCountdown -- ;
39
+ }
40
+ }
41
+ #endif
42
+
21
43
string logPath = null ;
22
44
string logPathArgument =
23
45
args . FirstOrDefault (
@@ -31,6 +53,23 @@ static void Main(string[] args)
31
53
logPath = logPathArgument . Substring ( 9 ) . Trim ( '"' ) ;
32
54
}
33
55
56
+ LogLevel logLevel = LogLevel . Normal ;
57
+ string logLevelArgument =
58
+ args . FirstOrDefault (
59
+ arg =>
60
+ arg . StartsWith (
61
+ "/logLevel:" ,
62
+ StringComparison . InvariantCultureIgnoreCase ) ) ;
63
+
64
+ if ( ! string . IsNullOrEmpty ( logLevelArgument ) )
65
+ {
66
+ // Attempt to parse the log level
67
+ Enum . TryParse < LogLevel > (
68
+ logLevelArgument . Substring ( 10 ) . Trim ( '"' ) ,
69
+ true ,
70
+ out logLevel ) ;
71
+ }
72
+
34
73
bool runDebugAdapter =
35
74
args . Any (
36
75
arg =>
@@ -54,46 +93,8 @@ static void Main(string[] args)
54
93
server = new LanguageServer ( ) ;
55
94
}
56
95
57
- // Start the logger with the specified log path
58
- // TODO: Set the level based on command line parameter
59
- Logger . Initialize ( logPath , LogLevel . Verbose ) ;
60
-
61
- #if DEBUG
62
- bool waitForDebugger =
63
- args . Any (
64
- arg =>
65
- string . Equals (
66
- arg ,
67
- "/waitForDebugger" ,
68
- StringComparison . InvariantCultureIgnoreCase ) ) ;
69
-
70
- // Should we wait for the debugger before starting?
71
- if ( waitForDebugger )
72
- {
73
- Logger . Write ( LogLevel . Normal , "Waiting for debugger to attach before continuing..." ) ;
74
-
75
- // Wait for 15 seconds and then continue
76
- int waitCountdown = 15 ;
77
- while ( ! Debugger . IsAttached && waitCountdown > 0 )
78
- {
79
- Thread . Sleep ( 1000 ) ;
80
- waitCountdown -- ;
81
- }
82
-
83
- if ( Debugger . IsAttached )
84
- {
85
- Logger . Write (
86
- LogLevel . Normal ,
87
- "Debugger attached, continuing startup sequence" ) ;
88
- }
89
- else if ( waitCountdown == 0 )
90
- {
91
- Logger . Write (
92
- LogLevel . Normal ,
93
- "Timed out while waiting for debugger to attach, continuing startup sequence" ) ;
94
- }
95
- }
96
- #endif
96
+ // Start the logger with the specified log path and level
97
+ Logger . Initialize ( logPath , logLevel ) ;
97
98
98
99
FileVersionInfo fileVersionInfo =
99
100
FileVersionInfo . GetVersionInfo (
0 commit comments