@@ -13,6 +13,7 @@ import { DelayTracker } from './delayTracker';
1313import { LaunchTarget , findLaunchTargets } from './launcher' ;
1414import { Request , RequestQueueCollection } from './requestQueue' ;
1515import TelemetryReporter from 'vscode-extension-telemetry' ;
16+ import * as os from 'os' ;
1617import * as path from 'path' ;
1718import * as protocol from './protocol' ;
1819import * as vscode from 'vscode' ;
@@ -539,7 +540,7 @@ export class OmniSharpServer {
539540 if ( packet . Event === 'log' ) {
540541 const entry = < { LogLevel : string ; Name : string ; Message : string ; } > packet . Body ;
541542 this . _logOutput ( entry . LogLevel , entry . Name , entry . Message ) ;
542- }
543+ }
543544 else {
544545 // fwd all other events
545546 this . _fireEvent ( packet . Event , packet . Body ) ;
@@ -569,13 +570,34 @@ export class OmniSharpServer {
569570 return id ;
570571 }
571572
573+ private static getLogLevelPrefix ( logLevel : string ) {
574+ switch ( logLevel ) {
575+ case "TRACE" : return "trce" ;
576+ case "DEBUG" : return "dbug" ;
577+ case "INFORMATION" : return "info" ;
578+ case "WARNING" : return "warn" ;
579+ case "ERROR" : return "fail" ;
580+ case "CRITICAL" : return "crit" ;
581+ default : throw new Error ( `Unknown log level value: ${ logLevel } ` ) ;
582+ }
583+ }
584+
585+ private _isFilterableOutput ( logLevel : string , name : string , message : string ) {
586+ // filter messages like: /codecheck: 200 339ms
587+ const timing200Pattern = / ^ \/ [ \/ \w ] + : 2 0 0 \d + m s / ;
588+
589+ return logLevel === "INFORMATION"
590+ && name === "OmniSharp.Middleware.LoggingMiddleware"
591+ && timing200Pattern . test ( message ) ;
592+ }
593+
572594 private _logOutput ( logLevel : string , name : string , message : string ) {
573- const timing200Pattern = / ^ \[ I N F O R M A T I O N : O m n i S h a r p .M i d d l e w a r e .L o g g i n g M i d d l e w a r e \] \/ [ \/ \w ] + : 2 0 0 \d + m s / ;
595+ if ( this . _debugMode || ! this . _isFilterableOutput ( logLevel , name , message ) ) {
596+ let output = `[${ OmniSharpServer . getLogLevelPrefix ( logLevel ) } ]: ${ name } ${ os . EOL } ${ message } ` ;
597+
598+ const newLinePlusPadding = os . EOL + " " ;
599+ output = output . replace ( os . EOL , newLinePlusPadding ) ;
574600
575- const output = `[${ logLevel } :${ name } ] ${ message } ` ;
576-
577- // strip stuff like: /codecheck: 200 339ms
578- if ( this . _debugMode || ! timing200Pattern . test ( output ) ) {
579601 this . _logger . appendLine ( output ) ;
580602 }
581603 }
0 commit comments