question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_this.logger.warning is not a function

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Browser:

  • Chrome version 74.0.3729.157
  • Firefox version 66.0.5
  • IE version XX
  • Edge version XX
  • Safari version XX

Library version


Library version: 1.0.1 (latest at this date of 24.5.19)



## Current behavior
I added logging as per https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-logging to end up with:

                    ```
logger: {
    localCallback: loggerCallback,
    level: LogLevel.Verbose,
    piiLoggingEnabled: true,
    correlationId: '1234',
}
```

I saw this error in the browser console:

```
core.js:15724 ERROR Error: Uncaught (in promise): TypeError: _this.logger.warning is not a function
TypeError: _this.logger.warning is not a function
    at UserAgentApplication.js:471
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (core.js:17299)
```

I had to add ALL logger fields to remove this error and get the application working.

```
logger: {
                        localCallback: loggerCallback,
                        level: LogLevel.Verbose,
                        piiLoggingEnabled: true,
                        correlationId: '1234',
                        logMessage: loggerCallback,
                        executeCallback: loggerCallback,
                        errorPii: singleMessage,
                        error: singleMessage,
                        warning: singleMessage,
                        warningPii: singleMessage,
                        info: singleMessage,
                        infoPii: singleMessage,
                        verbose: singleMessage,
                        verbosePii: singleMessage
}
```

## Expected behavior
I would think that most of those fields are optional - they could default to an already given loggerCallback.  Or the doco could be updated to say they need to be populated also.

I also added a comment to that https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-logging page to say it isn't showing all the fields of Logger (before I discovered the error).

## Minimal reproduction of the problem with instructions
Follow https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-logging

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
oehm-smithcommented, Jun 13, 2019

Specifically I now have:

        const loggerCallback = (logLevel, message, containsPii) => {
            console.log(`Auth: [${logLevel} ${message}`);
        };
        const logger = new Logger(
            loggerCallback,
            {correlationId: '1234', level: LogLevel.Info, piiLoggingEnabled: true});

        const data = await this.getIds();

        this.msal = new UserAgentApplication(
            {
                auth: {
                    clientId: data.clientId,
                    authority: 'https://login.microsoftonline.com/organizations',
                    redirectUri: Uri + '/login',
                },
                cache: {
                    cacheLocation: 'localStorage',
                    storeAuthStateInCookie: true
                },
                system: {
                    logger
                }
            }
        );
0reactions
gauravgoyal5commented, Dec 23, 2019

Is this working?

Read more comments on GitHub >

github_iconTop Results From Across the Web

this.logger.warn and this.logger.verbose is not a function
I'm trying to add papertrail logging to nest. I am using nest-winston module to inject the logger in bootstrap: // logging.ts import ...
Read more >
Winston logger.info is not a function - node.js
I've set up Winston with transports to MySQL and console and put it in a module called logger ...
Read more >
How to use the winston.config function in winston
When called with logger.debug("message", args) it should // act like ... const obj = {}; // Create the log directory if it does...
Read more >
nest-winston
One solution is to create the logger outside of the application lifecycle, using the createLogger function, and pass it to NestFactory.create .
Read more >
Logging facility for Python — Python 3.11.1 documentation
This module defines functions and classes which implement a flexible event logging system for ... Note that the root logger is created with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found