Skip to content

TypeError: Cannot read property 'replace' of undefined #3

@mark05e

Description

@mark05e

I tried to import the BBLog.gs file alone as a library and try to execute a test function - I get an error inside the console

The function I used to test is

function myFunction() {
  var lock = LockService.getScriptLock();
  var log = BBLog.getLog({
    level: BBLog.Level.ALL,  
    sheetName: 'Log',
    displayFunctionNames: BBLog.DisplayFunctionNames.YES,
    displayUserId: BBLog.DisplayUserId.EMAIL_FULL,
    lock: lock
  });
  log.info('Test log to GSheet at INFO level');
}

The error inside the console

TypeError: Cannot read property 'replace' of undefined
BBLog_._getFunctionName                @ BBLog.gs:908
convertUsingDefaultPatternLayout       @ BBLog.gs:871
BBLog_._log                            @ BBLog.gs:780
BBLog_.info                            @ BBLog.gs:331

and I get this log line inserted on the sheet

2022-03-24 09:42:36:600 -0400 000383 mark@XXXXX.com INFO     at BBLog_.info (BBLog:331:8) Test log to GSheet at INFO level

In another scenario, when I add the library directly to the sheet and run a modified test function...

function myFunction() {
  var lock = LockService.getScriptLock();
  var log = getLog({
    level: Level.ALL,  
    sheetName: 'Log',
    displayFunctionNames: DisplayFunctionNames.YES,
    displayUserId: DisplayUserId.EMAIL_FULL,
    lock: lock
  });
  log.info('Test log to GSheet at INFO level');
}

I get this output on the console

2022-03-24 10:15:33:363 -0400 000881 mark@XXXXX.com INFO     at myFunction (Tests:11:7) Test log to GSheet at INFO level

and this line on the sheet

2022-03-24 10:15:32:819 -0400 000337 mark@XXXXX.com INFO     at BBLog_.info (BBLog:331:8) Test log to GSheet at INFO level

I am wondering if this is because the configuration of depreciated runtime you have on your appsscript.json file?

  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "DEPRECATED_ES5"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions