Ideas for Improving Git Commits and Application Logs


3 min read

Between talks at DjangoCon and conversations with Jeff Triplett @webology and others, I've been thinking a lot about git commits and logging over the past week, so I put together some notes on the topic.


gitmoji is "an emoji guide for your commit messages". It provides a set of emoji paired with descriptions, which can help to provide visual cues to more quickly understand the purpose of commits.

The first place I heard of gitmoji was the openfun git handbook, which has some great tips for using what they describe as "emoji-driven commit message format".

Jeff has used emojis in commits as well, and recommended this excellent style guide:

A couple other good reads include:

The gitmoji website also has a page with related resources, including:

  • Plugins for Jetbrains IDEs, VSCode, Sublime Text, etc
  • Browser extension for gitmoji
  • Desktop gitmoji GUIs
  • etc

The Perfect Commit

When it comes to improving your Git Commits, also consider the advice from Simon Willison about the "Perfect Commit". A perfect commit includes the following:

  1. The implementation: a single, focused change
  2. Tests that demonstrate the implementation works
  3. Updated documentation reflecting the change
  4. A link to an issue thread providing further context

This is great advice for improving your contributions to software development, and it is something I am working to be more consistent on myself. You can read his post on this topic in detail at his blog.

Emojis in Logs

I have also begun using emojis in my logs for the same reasons one might use them in git commits.

In my primary django project, I added the following class to my project settings.

class Logmoji:
    Provides Emojis for more eye-catching logs

    curious: str = "๐Ÿคจ"
    paused: str = "๐Ÿ’ค"
    action_begin: str = "๐Ÿ"
    action_end: str = "๐Ÿ”š"

    money_related: str = "๐Ÿ’ต"
    email_related: str = "๐Ÿ“จ"
    time_related: str = "๐Ÿ“…"
    statistics_related: str = "๐Ÿ“ˆ"
    auth_related: str = "๐Ÿ”’"
    maintenance_related: str = "๐Ÿ”ง"

    success: str = "๐ŸŽ‰"
    denied: str = "โ›”"
    potential_issue: str = "๐Ÿ‘พ"
    warning: str = "โš ๏ธ"
    error: str = "๐Ÿ’€"
    critical: str = "๐Ÿ’ฃ"

Assuming you already have logging set up in your project, use this in the following ways:

from django.conf.settings import Logmoji

    item = ItemsModel.objects.get(id=1)
except ItemsModel.DoesNotExist as e:
    logger.warning(f"{Logmoji.curious} {e}")
๐Ÿคจ Exception: ItemsModel matching query does not exist.
from django.conf.settings import Logmoji

logger.warning(f"{Logmoji.auth_related} User is not logged in. Redirect to login.")
๐Ÿ”’ User is not logged in. Redirect to login.

You could, of course, directly add the emoji in the text of the log entry, but I like that if I change my mind about the emoji I want for a particular use, I can easily make one change in settings and the update propagates to all future log entries.


I hope you'll give these all a try and let me know how they work for you.