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

Add --debug (-d) option to CLI interface #599

Merged
merged 9 commits into from
Sep 27, 2024
Merged

Add --debug (-d) option to CLI interface #599

merged 9 commits into from
Sep 27, 2024

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Sep 27, 2024

This introduces --debug (-d) basic option to CLI interface. Users can enable debug logging by --debug=true easily.

Enable debug logs

Marp CLI is starting to use debug package to emit some useful debug logs for troubleshooting. If enabled debug option, Marp CLI will emit logs with marp-cli* filter pattern by default.

$ marp --debug=true --pdf slide.md
[  INFO ] Debug logging is enabled. (Filter pattern: marp-cli*)
  marp-cli:browser Browser manager configured: { protocol: 'cdp', timeout: undefined } +0ms
[  INFO ] Converting 1 markdown...
  marp-cli:browser:finder Start finding browser from chrome, edge, firefox ({ preferredPath: undefined }) +0ms
  marp-cli:browser:finder Found chrome: { path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', acceptedBrowsers: [ [class Bt extends Ke] { kind: 'chrome', protocol: 'webDriverBiDi' }, [class Pt extends Bt] { protocol: 'cdp' } ] } +1ms
  marp-cli:browser:finder Use browser: { path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', acceptedBrowsers: [ [class Bt extends Ke] { kind: 'chrome', protocol: 'webDriverBiDi' }, [class Pt extends Bt] { protocol: 'cdp' } ] } +0ms
  marp-cli:browser Use browser class for conversion: [class Pt extends Bt] { protocol: 'cdp' } +3ms
  marp-cli Saving file: /Users/yhatt/Documents/marp-test/slide.pdf +0ms
  marp-cli Saved: /Users/yhatt/Documents/marp-test/slide.pdf +1ms
[  INFO ] slide.md => slide.pdf

Custom filter pattern

Users also can set the custom filter pattern by --debug=<pattern>. This is equivalent to use DEBUG environment variable.

# Enable debug logging with starting "marp-cli:browser" except "marp-cli:browser:finder"
$ marp --debug "marp-cli:browser*,-marp-cli:browser:finder" --pdf slide.md
[  INFO ] Debug logging is enabled. (Filter pattern: marp-cli:browser*,-marp-cli:browser:finder)
  marp-cli:browser Browser manager configured: { protocol: 'cdp', timeout: undefined } +0ms
[  INFO ] Converting 1 markdown...
  marp-cli:browser Use browser class for conversion: [class Pt extends Bt] { protocol: 'cdp' } +3ms
[  INFO ] slide.md => slide.pdf

Full debug logs

To enable full debug logging including dependent packages, use --debug=all or --debug=full.

$ marp --debug=all --pdf slide.md
  portfinder:defaultHosts exports._defaultHosts is: [ '0.0.0.0', '127.0.0.1', '::1', 'fe80::1', 'fe80::4a4:a2be:45a8:4727', '192.168.2.114', 'fe80::2ca8:7bff:feb8:2d6f', 'fe80::2ca8:7bff:feb8:2d6f', 'fe80::6917:87b9:c047:1a59', 'fe80::66c7:2a83:6269:7d1c', 'fe80::f909:8cd8:2e4b:a8ca', 'fe80::ce81:b1c:bd2c:69e', 'fe80::34dd:3440:7cd7:b5ce', '192.168.64.1', 'fe80::183e:efff:fe4c:7264', 'fdd7:f6ac:b2fe:ff29:8fc:4431:745b:df49', 'fe80::1a17:5d03:2367:43f3', 'fe80::fa7:88c5:c0b6:312e', 'fe80::a7eb:f935:7f14:156b', null ] +0ms
[  INFO ] Debug logging is enabled. (Filter pattern: *)
  marp-cli:browser Browser manager configured: { protocol: 'cdp', timeout: undefined } +0ms
[  INFO ] Converting 1 markdown...
  marp-cli:browser:finder Start finding browser from chrome, edge, firefox ({ preferredPath: undefined }) +0ms
  marp-cli:browser:finder Found chrome: { path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', acceptedBrowsers: [ [class Bt extends Ke] { kind: 'chrome', protocol: 'webDriverBiDi' }, [class Pt extends Bt] { protocol: 'cdp' } ] } +1ms
  marp-cli:browser:finder Use browser: { path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', acceptedBrowsers: [ [class Bt extends Ke] { kind: 'chrome', protocol: 'webDriverBiDi' }, [class Pt extends Bt] { protocol: 'cdp' } ] } +0ms
  marp-cli:browser Use browser class for conversion: [class Pt extends Bt] { protocol: 'cdp' } +3ms
  marp-cli Saving file: /Users/yhatt/Documents/marp-test/slide.pdf +0ms
  marp-cli Saved: /Users/yhatt/Documents/marp-test/slide.pdf +1ms
  puppeteer:browsers:launcher Launching /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf --generate-pdf-document-outline --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes --enable-features=PdfOopif --user-data-dir=/var/folders/q3/skswxg4x7934y_xc5vjbyhrw0000gn/T/marp-cli-Xz7ON0flb2 --headless=new --hide-scrollbars --mute-audio about:blank --test-type --remote-debugging-pipe {
  detached: true,
  env: {},
  stdio: [ 'ignore', 'ignore', 'ignore', 'pipe', 'pipe' ]
} +0ms
  puppeteer:browsers:launcher Launched 99291 +2ms
  puppeteer:protocol:SEND ► [
  puppeteer:protocol:SEND ►   '{"method":"Target.setDiscoverTargets","params":{"discover":true,"filter":[{}]},"id":1}'
  puppeteer:protocol:SEND ► ] +0ms
  puppeteer:protocol:RECV ◀ [
  puppeteer:protocol:RECV ◀   '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"70D82644C9A6869E484558BA3D04503E","type":"page","title":"","url":"about:blank","attached":false,"canAccessOpener":false,"browserContextId":"0FFF71E353775CB45C0241ED0AEE5E0C"}}}'
  puppeteer:protocol:RECV ◀ ] +0ms
...

@yhatt yhatt merged commit 79ab9d9 into main Sep 27, 2024
13 checks passed
@yhatt yhatt deleted the debug-option branch September 27, 2024 22:15
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.

1 participant