Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWC - Logs not created for some lifecycle events when using new createLogger() pattern #518

Closed
jongpie opened this issue Jun 29, 2023 · 1 comment · Fixed by #577
Closed
Assignees
Labels
Layer: Logger Engine Items related to the core logging engine Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Type: Bug Something isn't working

Comments

@jongpie
Copy link
Owner

jongpie commented Jun 29, 2023

Reported by @shuylern in this discussion: #515

UPDATE

I was able to determine that the saveLog() was actually being executed prior to the logger actually finishing its creation.

I did this on the wire call which returned a forced Error from the Apex controller.

I added a setTimeout method that paused the saveLog() for 2.5 seconds after the logger creation was initiated. This resulted in the Log (error) being created without issue.

I am still interested in knowing if there is a delivered solution that I may have overlooked.

 @wire(returnSomeString)
    wiredReturnSomeString({ error, data }) {        
        if (data) {
            this.logger.info('>>> wire function return value: ' + data);
        } else if (error) {
            console.log('error in Wire');            
            const entry = this.logger.error('stuck here').setError(error).setRecordId(this.recordId).addTags([this.loggerDeleteByTag,'#LWC']);
            this.error = error;
            this.sleep(2500).then(() => { this.saveLogExample() });
        }
    }

saveLogExample() {
        console.log('running saveLog for btn');
        this.logger.setScenario(this.scenario);
        console.log(this.logger);
        //this.logger.saveLog('QUEUEABLE');
        this.logger.saveLog();
    }

    sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

Originally posted by @shuylern in #515 (comment)

@jongpie jongpie added Type: Bug Something isn't working Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Layer: Logger Engine Items related to the core logging engine labels Jun 30, 2023
jamessimone added a commit that referenced this issue Oct 12, 2023
jamessimone added a commit that referenced this issue Oct 12, 2023
jongpie pushed a commit that referenced this issue Oct 23, 2023
jongpie pushed a commit that referenced this issue Oct 24, 2023
…mounted instances (#577)

* Fixed #518 by calling saveLog() as soon as createLogger() has finished loading for pending log messages
@jongpie
Copy link
Owner Author

jongpie commented Oct 24, 2023

@shuylern this should now be fixed in the latest release, v4.11.12 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Logger Engine Items related to the core logging engine Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Type: Bug Something isn't working
Projects
None yet
2 participants