zerosleeps

Since 2010

Log HTTP 5xx responses in Django

By default, in a production environment where setting DEBUG is false, Django sends log messages with ERROR or CRITICAL levels to AdminEmailHandler. This includes HTTP 5xx responses, which are handled by the django.request logger.

If you don’t have outbound email configured you lose these errors.

Python’s logging.StreamHandler defaults to sending output to stderr, and most of the time my Django applications are managed by systemd service units which default to passing stdout and stderr to systemd’s journal.

Put all of that knowledge together and here’s the delightfully simple LOGGING configuration I usually add to my production settings:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "handlers": {
        "stderr": {
            "class": "logging.StreamHandler"
        }
    },
    "loggers": {
        "django.request": {
            "level": "ERROR",
            "handlers": ["stderr"]
        }
    }
}

I can then fumble about with journald as required.

Apple continues their mission to drive me away

I used Pages to create a document a couple of weeks ago - something I very rarely do - and was presented with this advertisement for Apple Creator Studio when I selected a template:

Screenshot of advertisement for Apple Creator Studio

Then at the weekend I got this advertisement on my iPhone’s lock screen after paying for breakfast:

Screenshot of notification to join rewards program

No idea how I turn that kind of crap off, because “Offers & Promotions” is already disabled in my Apple Wallet notification settings:

Screenshot of Apple Wallet notification settings

Then a load of sloppiness this morning after updating my iPhone to iOS 26.4 when I was asked to double-click the side button to let stuff verify my age via Apple Wallet. That was the gist of it anyway. I don’t want that shit so I dismissed the prompt without thinking too much about it.

But then it threw up a dialogue with this content (I couldn’t take screenshots):

Parental Consent

To provide parental consent to create this child account, you will need to verify your identity by confirming the password for your account.

I’m not creating a child account! I’m not creating any account!

I played the game, then got this message. I haven’t replaced my actual email address - this is exactly what the message said, bold text and all:

Verification Code

To provide parental consent to create this child account, enter the verification code sent to this email address: email

Wealthiest company in the world. Thousands of employees. The premium Apple experience is a thing of the past.

The weight of online advertising

A couple of articles have been doing the rounds inside my circles over the last couple of weeks: the first is titled “The 49MB Web Page” by Shubham Bose and the other is by Stuart Breckenridge about PC Gamer pages which download gigabytes of data if left alone.

I’ve never had to get really dirty with advertising, but on the few occasions that I have been in meetings with marketing departments, I’ve never gotten the impression that online marketing/advertising people know whether their “campaigns” actually do anything. They just do the things they do because that’s what they’ve always done.

I have testimony! (Kind of.) The application I work with generates and encrypts all URLs for all authenticated users (it was born before cookies were invented). Every link/button/form destination/GET/POST etc. has a unique URL, and a different URL every time a user loads the same page. Anything that attempts to count page visits by URL therefore fails miserably - all you end up with is an infinite list of URLs, all of which have exactly one page visit.

I explained this to the marketing department at one of the larger universities I’ve worked at, and they just didn’t care. They “needed” the tracking code added to the application anyway. It gave them utterly useless data and a lot of it. But they were delighted because, I don’t know, there was a number on a dashboard somewhere that kept going up?

It wasn’t to advertise to customers inside the application but I assume they wanted to track users to try and work out which “campaigns” had led to certain outcomes. It doesn’t take a huge amount of creativity to imagine how that kind of desperation and cluelessness leads to pages that make hundreds of slimy network requests.