@@ -18,6 +18,28 @@ class Program
1818 [ STAThread ]
1919 static void Main ( string [ ] args )
2020 {
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+
2143 string logPath = null ;
2244 string logPathArgument =
2345 args . FirstOrDefault (
@@ -31,6 +53,23 @@ static void Main(string[] args)
3153 logPath = logPathArgument . Substring ( 9 ) . Trim ( '"' ) ;
3254 }
3355
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+
3473 bool runDebugAdapter =
3574 args . Any (
3675 arg =>
@@ -54,46 +93,8 @@ static void Main(string[] args)
5493 server = new LanguageServer ( ) ;
5594 }
5695
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 ) ;
9798
9899 FileVersionInfo fileVersionInfo =
99100 FileVersionInfo . GetVersionInfo (
0 commit comments