Skip to content

Commit 6599bc2

Browse files
valentingcanova
andauthored
Make extractGeckoLogs() not fake the D/ log level if the log module already contains it (#5811)
Co-authored-by: Nazım Can Altınova <canaltinova@gmail.com>
1 parent bfb8cde commit 6599bc2

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/test/unit/window-console.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,39 @@ describe('console-accessible values on the window object', function () {
7979
`);
8080
});
8181

82+
it('can extract gecko logs with log level already in module', function () {
83+
const profile = getProfileWithMarkers([
84+
[
85+
'LogMessages',
86+
170,
87+
null,
88+
{
89+
type: 'Log',
90+
module: 'D/nsHttp',
91+
name: 'ParentChannelListener::ParentChannelListener [this=7fb5e19b98d0, next=7fb5f48f2320]',
92+
},
93+
],
94+
[
95+
'LogMessages',
96+
190,
97+
null,
98+
{
99+
type: 'Log',
100+
name: 'nsJARChannel::nsJARChannel [this=0x87f1ec80]\n',
101+
module: 'D/nsJarProtocol',
102+
},
103+
],
104+
]);
105+
const store = storeWithProfile(profile);
106+
const target: MixedObject = {};
107+
addDataToWindowObject(store.getState, store.dispatch, target);
108+
const result = (target as any).extractGeckoLogs();
109+
expect(result).toBe(stripIndent`
110+
1970-01-01 00:00:00.170000000 UTC - [Unknown Process 0: Empty]: D/nsHttp ParentChannelListener::ParentChannelListener [this=7fb5e19b98d0, next=7fb5f48f2320]
111+
1970-01-01 00:00:00.190000000 UTC - [Unknown Process 0: Empty]: D/nsJarProtocol nsJARChannel::nsJARChannel [this=0x87f1ec80]
112+
`);
113+
});
114+
82115
describe('totalMarkerDuration', function () {
83116
function setup(): ExtraPropertiesOnWindowForConsole {
84117
jest.spyOn(console, 'log').mockImplementation(() => {});

src/utils/window-console.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,12 @@ export function addDataToWindowObject(
323323
) {
324324
const strTimestamp = d2s(profile.meta.startTime + markerStartTime);
325325
const processName = thread.processName ?? 'Unknown Process';
326-
// TODO: lying about the log level as it's not available yet in the markers
327-
const statement = `${strTimestamp} - [${processName} ${thread.pid}: ${thread.name}]: D/${(data as any).module} ${(data as any).name.trim()}`;
326+
327+
// The log module may contain the log level for profiles captured after bug 1995503.
328+
// If the log module does not contain /, we fake it to D/module
329+
const logModule = (data as any).module;
330+
const prefix = logModule.includes('/') ? '' : 'D/';
331+
const statement = `${strTimestamp} - [${processName} ${thread.pid}: ${thread.name}]: ${prefix}${logModule} ${(data as any).name.trim()}`;
328332
logs.push(statement);
329333
}
330334
}

0 commit comments

Comments
 (0)