-
Notifications
You must be signed in to change notification settings - Fork 110
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
Chrome: SourceMap links not working #289
Comments
hello, I have the same problem. Angular version 13.2.0: |
Is this lib still maintained...? |
Yes it is but I am the only active maintainer for now I am open to PR if you have time About this issue, is the location of the log line correct ? (In your example "./src/app/core/components/.../grid-settings-store.service.ts:46:0") |
Hello and thank you. Yes, the position is correct only the link itself is not working. |
This works!! So many thanks! So together with the fix for the missing linebreak before the actual message the writer should look like this: protected override prepareMetaString(metadata: INGXLoggerMetadata, config: INGXLoggerConfig): string {
// Fix link to the source file in the console
const fileName = metadata.fileName?.charAt(0) === '.'
? 'webpack://' + metadata.fileName?.substring(1)
: metadata.fileName
// We want to start the actual log message on a new line (after level + source link)
return super.prepareMetaString({ ...metadata, fileName }, config) + '\n'
} (For some reason there is still an additional space added before the start of the actual message but it's already way more readable). |
Above method does not work for Angular 16. private getMapping(sourceMap: SourceMapPayload, position: INGXLoggerLogPosition): INGXLoggerLogPosition {
try {
const rawSourceMap: RawSourceMap = {
file: sourceMap.file,
mappings: sourceMap.mappings,
names: sourceMap.names,
sourceRoot: sourceMap.sourceRoot,
sources: sourceMap.sources,
sourcesContent: sourceMap.sourcesContent as string[],
version: `${sourceMap.version}`,
};
const sourceMapConsumer = new SourceMapConsumer(rawSourceMap);
const mappedPosition: MappedPosition = sourceMapConsumer.originalPositionFor({
line: Number(position.lineNumber || 1),
column: Number(position.columnNumber || 1),
});
return { fileName: mappedPosition.source, lineNumber: mappedPosition.line, columnNumber: mappedPosition.column };
} catch (e) {
return { fileName: 'unknown', lineNumber: 0, columnNumber: 0 };
}
} If anyone wants to create a PR go ahead. |
Hi there,
loving this library, using it every day with pure joy! :)
One of the coolest features might be the generated links to jump directly to the source. For some reason, that doesn't work for me. Clicking on one of the links just opens a new tab to about:blank instead:
(after clicking on the link)
Manually, I can open the file in the DevTools just fine:
Angular version 13.0.2:
ngx-logger version: 5.0.7
Chrome version: 97.0.4692.99 (running in debug mode without any plugins enabled)
Configuration (in app.module.ts):
ng serve
Build config from angular.json:
Did I miss something?
Thank you!
The text was updated successfully, but these errors were encountered: