RegioHelden / django-scrubber

Anonymizer for Django database data
Other
25 stars 10 forks source link

How to activate logging #13

Closed GitRon closed 4 years ago

GitRon commented 4 years ago

Hi @costela

I saw that there are some logs within the scrub_data command but I didn't mange to let it log somewhere.

Could you provide an example? I'd be willing to update the docs then 😃

Best Ronny

costela commented 4 years ago

There's nothing magical about the logging. Since we're inside a django management command, we're subject to django's logging settings. Please check that your settings are not too strict and allow logging from django_scrubber.* at the level you wish.

GitRon commented 4 years ago

Hm, I tried to set up the logger like I would do normally, but nothing happened.

    LOGGING['loggers']['scrub_data'] = {
        'handlers': ['console'],
        'propagate': True,
        'level': 'DEBUG',
    }

I guess I need to use scrub_data as key because it says in the MC: logger = logging.getLogger(__name__)

costela commented 4 years ago

The key is the module path, so it should start with django_scrubber. (wildcards work, so django_scrubber.* should be all you need)

GitRon commented 4 years ago

Like this?

    LOGGING['loggers']['django_scrubber.*'] = {
        'handlers': ['console'],
        'propagate': True,
        'level': 'DEBUG',
    }
costela commented 4 years ago

Yes, assuming you have LOGGING['handlers']['console'] set to something reasonable, like here.

GitRon commented 4 years ago

Hm, maybe some weird setup in my project. Everything looks fine but nothing is showing up in the console...

costela commented 4 years ago

I'll close this for now, but let us know if there more reason to think the problem might be on our side.

GitRon commented 4 years ago

Ok, it works like this:

LOGGING['loggers']['django_scrubber.scrubbers'] = {
        'handlers': ['console'],
        'propagate': True,
        'level': 'DEBUG',
    }

Maybe add this to the docs? Not seeing ANYTHING for a process that can take a long time is not very satisfying.

GitRon commented 4 years ago

Secondly, it would be awesome if the logger would log which model is currently being scrubbed and maybe how many records have been processed (I still don't get the magic how you make a query 😅 )

@costela Maybe we can create a separate issue for this one?

GitRon commented 4 years ago

Create a PR for post #1 and an issue for post #2: https://github.com/RegioHelden/django-scrubber/issues/18

So we can let this issue here rest in peace ;)