Skip to content

Export a tool to extract gecko logs from a profile#4973

Merged
julienw merged 1 commit into
firefox-devtools:mainfrom
julienw:extract-mozlog
Sep 23, 2024
Merged

Export a tool to extract gecko logs from a profile#4973
julienw merged 1 commit into
firefox-devtools:mainfrom
julienw:extract-mozlog

Conversation

@julienw

@julienw julienw commented Apr 30, 2024

Copy link
Copy Markdown
Contributor

deploy preview

One can use it this way:

// In the Devtools' Web Console
l = extractGeckoLogs()

// Then
// Either download to a file:
saveToDisk(l)

// or copy to the clipboard:
copy(l)

This takes into account the current range (both selection range and committed range).

It is a little bit slow because running inside the web console runs the code only in the JS interpreter and never starts the JIT (I think). But I think it's still OK.

Fixes #4660

@codecov

codecov Bot commented Apr 30, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.44%. Comparing base (1507cdd) to head (a457ad3).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4973      +/-   ##
==========================================
+ Coverage   88.43%   88.44%   +0.01%     
==========================================
  Files         304      304              
  Lines       27581    27607      +26     
  Branches     7458     7465       +7     
==========================================
+ Hits        24390    24416      +26     
  Misses       2963     2963              
  Partials      228      228              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@julienw julienw force-pushed the extract-mozlog branch 2 times, most recently from 7610fed to 28b7d5f Compare April 30, 2024 17:00
@julienw julienw force-pushed the extract-mozlog branch 3 times, most recently from 659379e to a6f03e9 Compare September 18, 2024 13:16
@julienw julienw changed the title [deploy preview] Export a tool to extract gecko logs from a profile Export a tool to extract gecko logs from a profile Sep 18, 2024
@acreskeyMoz

Copy link
Copy Markdown

Hey @julienw -- this seems to work very well for me!

I've asked the necko folks to add feedback as well.

• The output didn't seem to be recognized by logan -- there might be a small export change required (this is a guess)
Current export: [Parent Process 158395 Socket Thread] D/nsSocketTransport engaging
But when I capture MOZ_LOG's natively: [Parent 87530: Socket Thread]: D/nsSocketTransport engaging

• Naturally a button or similar would be better than console commands :)
• I didn't find the performance to be a problem at all.

@valenting valenting left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great, @julienw
I've confirmed that with my suggested change the logs can be loaded into https://mozilla-necko.github.io/logan/

Thanks!

Comment thread src/utils/window-console.js Outdated
);
const processName = thread.processName ?? 'Unknown Process';
// TODO: lying about the log level as it's not available yet in the markers
const statement = `${strTimestamp} - [${processName} ${thread.pid} ${thread.name}] D/${data.module} ${data.name.trim()}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const statement = `${strTimestamp} - [${processName} ${thread.pid} ${thread.name}] D/${data.module} ${data.name.trim()}`;
const statement = `${strTimestamp} - [${processName} ${thread.pid} ${thread.name}]: D/${data.module} ${data.name.trim()}`;

The format for MOZ_LOG has a colon after the ]

@KershawChang

Copy link
Copy Markdown

I've looked at the output log and it looks great!
Thank you.

@julienw

julienw commented Sep 19, 2024

Copy link
Copy Markdown
Contributor Author

Thanks all, I made the requested changes and added a test! I also tested after the changes that logan would be able to import the resulting file.

This should now be ready for review :-)

@julienw julienw requested a review from canova September 19, 2024 09:42

@canova canova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

Comment thread src/utils/window-console.js Outdated
return `${d.getFullYear()}-${pad(d.getUTCMonth() + 1, 2)}-${pad(d.getUTCDate(), 2)} ${pad(d.getUTCHours(), 2)}:${pad(d.getUTCMinutes(), 2)}:${pad(d.getUTCSeconds(), 2)}.${pad(d.getUTCMilliseconds(), 3)}${pad(ns, 6)} UTC`;
}

const all = [];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be better to name it to something like logs or allLogs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, this was a leftover from the hacky origin of this PR. :-) changed it to logs

@julienw julienw merged commit 91fe71e into firefox-devtools:main Sep 23, 2024
@julienw julienw mentioned this pull request Sep 23, 2024
julienw added a commit that referenced this pull request Sep 23, 2024
[Julien Wajsberg] Two optimizations for the marker chart (#5121)
[Nazım Can Altınova] [Tab selector 5] Add a tab selector component and implement tab switching (#5093)
[Julien Wajsberg] Support profiling from the toolbox in Thunderbird Release (#5135)
[Richard Fine] Add a dedicated symbolication tool (#5123)
[Julien Wajsberg] Export a tool to extract gecko logs from a profile (#4973)

Shout-out to our localizers:
de: Michael Köhler
el: Jim Spentzos
en-CA: chutten
en-GB: Ian Neal
es-CL: ravmn
fr: Théo Chevalier
fy-NL: Fjoerfoks
ia: Melo46
it: Francesco Lodolo [:flod]
nl: Mark Heijl
pt-BR: Marcelo Ghelman
ru: Valery Ledovskoy
sv-SE: Andreas Pettersson
uk: Lobodzets
zh-CN: Olvcpr423
zh-TW: Pin-guang Chen
@acreskeyMoz

Copy link
Copy Markdown

Used this again today, very nice ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add a method to export MozLog's captured by the Profiler

5 participants