@@ -369,12 +369,14 @@ export class LoggerWithoutCallSite {
369369 const relevantCallSites : NodeJS . CallSite [ ] = callSites . splice (
370370 this . settings . ignoreStackLevels
371371 ) ;
372- const stackFrame : NodeJS . CallSite = this . _callSiteWrapper (
373- relevantCallSites [ 0 ]
374- ) ;
375- const stackFrameObject : IStackFrame = LoggerHelper . toStackFrameObject (
376- stackFrame
377- ) ;
372+ const stackFrame : NodeJS . CallSite | undefined =
373+ relevantCallSites [ 0 ] != null
374+ ? this . _callSiteWrapper ( relevantCallSites [ 0 ] )
375+ : undefined ;
376+ const stackFrameObject : IStackFrame | undefined =
377+ stackFrame != null
378+ ? LoggerHelper . toStackFrameObject ( stackFrame )
379+ : undefined ;
378380
379381 const requestId : string | undefined =
380382 this . settings . requestId instanceof Function
@@ -389,15 +391,15 @@ export class LoggerWithoutCallSite {
389391 date : new Date ( ) ,
390392 logLevel : logLevel ,
391393 logLevelId : this . _logLevels . indexOf ( logLevel ) as TLogLevelId ,
392- filePath : stackFrameObject . filePath ,
393- fullFilePath : stackFrameObject . fullFilePath ,
394- fileName : stackFrameObject . fileName ,
395- lineNumber : stackFrameObject . lineNumber ,
396- columnNumber : stackFrameObject . columnNumber ,
397- isConstructor : stackFrameObject . isConstructor ,
398- functionName : stackFrameObject . functionName ,
399- typeName : stackFrameObject . typeName ,
400- methodName : stackFrameObject . methodName ,
394+ filePath : stackFrameObject ? .filePath ,
395+ fullFilePath : stackFrameObject ? .fullFilePath ,
396+ fileName : stackFrameObject ? .fileName ,
397+ lineNumber : stackFrameObject ? .lineNumber ,
398+ columnNumber : stackFrameObject ? .columnNumber ,
399+ isConstructor : stackFrameObject ? .isConstructor ,
400+ functionName : stackFrameObject ? .functionName ,
401+ typeName : stackFrameObject ? .typeName ,
402+ methodName : stackFrameObject ? .methodName ,
401403 argumentsArray : [ ] ,
402404 toJSON : ( ) => this . _logObjectToJson ( logObject ) ,
403405 } ;
@@ -457,11 +459,14 @@ export class LoggerWithoutCallSite {
457459 this . _callSiteWrapper ( relevantCallSites [ 0 ] )
458460 ) ;
459461 if ( exposeErrorCodeFrame && errorCallSite . lineNumber != null ) {
460- if ( errorCallSite . fullFilePath . indexOf ( "node_modules" ) < 0 ) {
462+ if (
463+ errorCallSite . fullFilePath != null &&
464+ errorCallSite . fullFilePath . indexOf ( "node_modules" ) < 0
465+ ) {
461466 errorObject . codeFrame = LoggerHelper . _getCodeFrame (
462467 errorCallSite . fullFilePath ,
463468 errorCallSite . lineNumber ,
464- errorCallSite . columnNumber ,
469+ errorCallSite ? .columnNumber ,
465470 this . settings . exposeErrorCodeFrameLinesBeforeAndAfter
466471 ) ;
467472 }
@@ -576,6 +581,7 @@ export class LoggerWithoutCallSite {
576581 if (
577582 this . settings . displayFilePath === "displayAll" ||
578583 ( this . settings . displayFilePath === "hideNodeModulesOnly" &&
584+ logObject . filePath != null &&
579585 logObject . filePath . indexOf ( "node_modules" ) < 0 )
580586 ) {
581587 fileLocation = `${ logObject . filePath } :${ logObject . lineNumber } ` ;
0 commit comments