Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
jongpie committed Sep 20, 2024
1 parent f2fb679 commit bf2a3ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ const LogEntryBuilder = class {
this.#componentLogEntry.error.type = exception.body.exceptionType;
} else {
this.#componentLogEntry.error.message = exception.message;
this.#componentLogEntry.error.stackTrace = new LoggerStackTrace().parse(error);
this.#componentLogEntry.error.type = 'JavaScript.' + error.name;
this.#componentLogEntry.error.stackTrace = new LoggerStackTrace().parse(exception);
this.#componentLogEntry.error.type = 'JavaScript.' + exception.name;
}
return this;
}
Expand Down
21 changes: 21 additions & 0 deletions nebula-logger/core/main/logger-engine/lwc/logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ import { createLoggerService as createLogger, getLoggerService as getLogger } fr
export default class Logger extends LightningElement {
#loggerService;

constructor() {
super();
Object.getOwnPropertyNames(Object.getPrototypeOf(this)).forEach(methodName => {
const originalMethod = this[methodName];

// Skip constructor and non-function properties
if (methodName !== 'constructor' && methodName !== 'connectedCallback' && typeof originalMethod === 'function') {
this[methodName] = (...args) => {
console.log(`Calling ${methodName} with arguments:`, args);

// Call the original method
const result = originalMethod.apply(this, args);

console.log(`${methodName} returned:`, result);

return result;
};
}
});
}

async connectedCallback() {
this.#loggerService = await createLogger();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import { api, LightningElement, wire } from 'lwc';
import returnSomeString from '@salesforce/apex/LoggerLWCDemoController.returnSomeString';
import throwSomeError from '@salesforce/apex/LoggerLWCDemoController.throwSomeError';
import { getLogger } from 'c/logger';
import Logger, { getLogger } from 'c/logger';

export default class LoggerLWCImportDemo extends LightningElement {
export default class LoggerLWCImportDemo extends Logger {
someBoolean = false;

message = 'Hello, world!';
Expand Down

0 comments on commit bf2a3ab

Please sign in to comment.