question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Logging Class not working

See original GitHub issue

Hi ! I am currently trying to use a custom EVENT_LOGGER in superset, i added the code snippets from the official doc but it isn’t working: I think the EVENT_LOGGER has changed and isn’t the default DBEventLogger() anymore because we have some new logs on stdout, and there are no more “action logs” in the superset UI. However, my JSONStdOutEventLogger() isn’t used either, i added some prints in the log method to see if it was even called, and it doesn’t seem so.

Here are the code snippets i added:

event_logger.py: |-
    from superset.utils.log import AbstractEventLogger
    import json
    class JSONStdOutEventLogger(AbstractEventLogger):
        def log(self, user_id, action, *args, **kwargs):
          records = kwargs.get('records', list())
          dashboard_id = kwargs.get('dashboard_id')
          slice_id = kwargs.get('slice_id')
          duration_ms = kwargs.get('duration_ms')
          referrer = kwargs.get('referrer')
          print("bip boup 1")
          for record in records:
              log = dict(
                  action=action,
                  json=record,
                  dashboard_id=dashboard_id,
                  slice_id=slice_id,
                  duration_ms=duration_ms,
                  referrer=referrer,
                  user_id=user_id
              )
              print(json.dumps(log))
              print("bip boup 2")

configFile: |-
...
  from event_logger import JSONStdOutEventLogger
  EVENT_LOGGER = JSONStdOutEventLogger()

Expected results

I expect the custom log method to be used (ie to see “bip boup” and “bip boup 2” on stdout)

Actual results

Some debug logs and logs on the requests done are on stdout (cf screenshot)

Screenshots

image

Environment

  • superset version: 1.0.1
  • python version: 3.8.8
  • node.js version: 12

I hope i’m not missing something, thank in advance for your help !

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wiktor2200commented, Jul 12, 2022

Hi! My last PR is merged, finally I’ve just updated docs. I think this issue could be closed now? @bouleq could you close it? Or is it anything more still needed for this issue?

1reaction
bouleqcommented, Mar 23, 2022

Sure you can do it, hope it can help people.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: custom logging across all modules - Stack Overflow
So far I've been able to make my class that does it all (attaching formatters, handlers and setting loglevel) work by defining log...
Read more >
Custom Logger class - python - Code Review Stack Exchange
My custom Logger class works just fine. However, the class is not intended for making instances of. Because there is really no reason...
Read more >
Custom Logging Class not working · Issue #217 - GitHub
Hi ! I am currently trying to use a custom EVENT_LOGGER in superset, i added the code snippets from the official doc but...
Read more >
How to Get Started with Logging in Python - Better Stack
In the next section, we will discuss some features of the logging module that can help us solve this problem. Setting up custom...
Read more >
Logging HOWTO — Python 3.11.1 documentation
You can create your own log destination class if you have special requirements not met by any of the built-in handler classes. By...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found