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

Console duplicated lines #151

Closed
xmaysonnave opened this issue Jun 6, 2020 · 1 comment
Closed

Console duplicated lines #151

xmaysonnave opened this issue Jun 6, 2020 · 1 comment

Comments

@xmaysonnave
Copy link

xmaysonnave commented Jun 6, 2020

eruda 2.3.3
loglevel 1.6.8
Chrome Version 83.0.4103.97 (Official Build) (64-bit)

Here is the way I initialize eruda :
Dynamically loaded from:
https://cdn.jsdelivr.net/npm/eruda@2.3.3/eruda.min.js

The code is available here:
https://github.com/xmaysonnave/tiddlywiki-ipfs/blob/ed97afd1b75ad984ea51c98507fec6c7e80f133f/src/ipfs-action.js#L514

IpfsAction.prototype.handleMobileConsole = async function (tiddler) {
  // Load mobile console if applicable
  if (typeof window.eruda === 'undefined') {
    try {
      // Load eruda
      await $tw.ipfs.ipfsBundle.ipfsLoader.loadErudaLibrary()
    } catch (error) {
      this.getLogger().error(error)
      throw new Error(error.message)
    }
    const erudaContainer = window.document.createElement('div')
    window.document.body.appendChild(erudaContainer)
    window.eruda.init({
      container: erudaContainer,
      tool: ['console'],
      useShadowDom: true,
      autoScale: true
    })
    // Inherit font
    erudaContainer.style.fontFamily = 'inherit'
    // Preserve user preference if any, default is 80
    if (window.eruda.get().config.get('displaySize') === 80) {
      window.eruda.get().config.set('displaySize', 40)
    }
    // Preserve user preference if any, default is 0.95
    if (window.eruda.get().config.get('transparency') === 0.95) {
      window.eruda.get().config.set('transparency', 1)
    }
    // Hide Eruda button
    if (window.eruda._shadowRoot !== undefined) {
      const btn = window.eruda._shadowRoot.querySelector('.eruda-entry-btn')
      if (btn !== undefined) {
        btn.style.display = 'none'
      }
    }
    // Console settings
    const console = window.eruda.get('console')
    console.config.set('asyncRender', true)
    console.config.set('catchGlobalErr', true)
    console.config.set('displayExtraInfo', false)
    console.config.set('displayGetterVal', true)
    console.config.set('displayUnenumerable', true)
    console.config.set('jsExecution', true)
    console.config.set('maxLogNum', 'infinite')
    console.config.set('overrideConsole', true)
    this.getLogger().info('Mobile console has been loaded...')
  }
  if (this.console === false) {
    window.eruda.show()
    window.eruda.show('console')
    this.console = true
  } else {
    window.eruda.hide()
    this.console = false
  }
}

The following screenshot shows the issue I'm facing:

  • on mobile lines are duplicated
  • on desktop same issue

ksnip_20200606-092036

If I don't set :
console.config.set('overrideConsole', true)

Lines are not duplicated but many log output are missing.

Thanks

@xmaysonnave
Copy link
Author

I'm using loglevel and the problem came from there.
I need to create a new logger AFTER eruda has been initialized and then random missing output are vanished and no more duplicated lines.
Thanks.
PS: Feel free to close this ticket.

@surunzi surunzi closed this as completed Jun 14, 2020
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

No branches or pull requests

2 participants