Download / ulog

The universal logger
https://ulog.js.org
MIT License
88 stars 19 forks source link

Can't get the `drain` functionality to work in the browser #39

Closed ifeanyiisitor closed 3 years ago

ifeanyiisitor commented 3 years ago

I'm trying to test out the drain functionality in the browser but I'm not sure how to set it up. This is what I tried

import ulog from 'ulog'

ulog.use({
  outputs: {
    custom: {
      log: function (...args) {
        console.log(args)
      },
    },
  },
})

ulog.set('output', '*=custom')

This didn't seem to work, and neither did doing

localStorage.setItem('log_drain', '*=custom')

I'm expecting the custom.log function to be called but it's not being called. How would I get this to work in the browser?

Download commented 3 years ago

Please have a look at this codepen. It sets a custom output. I do think there are still bugs. Setting the drain does not seem to work.

I will keep this issue open for now and report back here. Thank you for your interest in ulog and taking the trouble to report issues. It is much appreciated!

ifeanyiisitor commented 3 years ago

Hey thanks for your reply and glad I can help. Interestingly it seems that it works in the codepen example, yet it doesn't work in my nextjs sample app. I confirmed that its ulog@2.0.0-beta.10 that I'm installing and I'm doing exactly this...

import ulog from 'ulog'

export const log = ulog('sample-app')

ulog.use({
  outputs: {
    custom: {
      log: function (...args) {
        console.dir('custom...', args)
      },
    },
    drain: {
      log: function (...args) {
        console.dir('drain...', args)
      },
    },
  },
})

ulog.set('drain', 'drain')

Note sure why it works in your codepen but not in my app. Setting ulog.set('output', 'custom') works as expected though. So only the drain setting is the issue.

Download commented 3 years ago

I have redesigned the way outputs, formats and levels work together (or not!) several times. I think I just messed up between the betas.

Download commented 3 years ago

I'm actually redesigning it yet again. I'm in the process of making static formatters (the ones that don't mess up the call stack) much more powerful and configurable. Formatters work on outputs and the drain and in the process of redesigning the formatting pipeline so it could benefit from static formatters I also am redesigning how outputs and the drain work. So please ignore the issue for the drain for a bit more; I'm working on it.

ifeanyiisitor commented 3 years ago

👍

Download commented 3 years ago

@ifeanyiisitor Please check out the latest beta and let me know what you think. Feel free to re-open if you still encounter issues.