Skip to main content

Linelog

Summary

linelog is a CLI program that scans your local git repositories generates a summary of your total lines of code committed, broken down by language. For example, if I run linelog -a on my main desktop computer, it generates this: example-day

This isn't very exciting since I've not done much today (look, work-life balance is important.) With the -d flag you can look back further in time, and see the results as a nice graph: example-2week

Hey, wait a second!, you exclaim, This very project has more than 651 lines of Python code, and most of it was committed in that very interval! That's very astute of you, you have a real eagle eye. The discrepency comes from the fact that linelog does its best to count logical lines of code by skipping comments and whitespaces. You can customize what counts as a line for a given filetype; see the section on configuration

Installation

Arch Linux and kin (AUR)

linelog is on the Arch User Repository (AUR). You can get it in the usual manner with the AUR downloader of your choice:

$ yay -S linelog

Other Linuxes/Unixes (Pip)

linelog is on PyPI. Install it with pip or pipx:

pipx install linelog

Usage and Configuration

linelog uses this algorithm to count lines (simplified a bit):

  • For the specified repository, iterate pairwise through all commits in the specified timeframe that have the specified author.
  • For each pair of sequential commits, apply the pattern matches specified in the config to count the total lines for each file. Then subtract the earlier line count from the later.
    • If the difference is negative (the later commit has fewer net lines), it is instead counted as zero. This is essentially the only part of the counting behavior that the user cannot edit directly, both for technical and philosophical reasons. The point of linelog is to get a broad sense of productivity over a timespan, using lines of code written as a proxy. It is not meant to work as a diff generator - there are many many tools out there for that!
  • Results for each filetype are collected and then summed for the final result.

Usage

A summary of available options is viewable with linelog --help

usage: linelog [-h] [-u USERNAME] [-c] [-r] [-a] [-d DAYS] [start_dir]

positional arguments:
  start_dir             The directory to scan. Defaults to the current working
                        directory if unspecified

options:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        Limit the scan to commits by this username. If
                        unspecified, the username set in the global git config
                        file (if present) is used. If no username is given by
                        either of these methods, or if the -c option is
                        passed, all commits are considered regardless of
                        author
  -c, --all-commits     Consider all commits by any user. Overrides the
                        --username option if present.
  -r, --recursive       If no repository is found in the given directory,
                        search all subdirectories recursively and consider any
                        repositories found there. If the top level directory
                        is a repository, this does nothing.
  -a, --all             Start the scan in the home directory, and search all
                        subdirectories for repositories. Same as 'linelog ~
                        -r'
  -d DAYS, --days DAYS  The number of days in the past to traverse when
                        scanning a repository for relevant commits. If
                        unspecified defaults to 1 (only today). The output
                        graph is only generated if this is greater than one

The Config File

linelog generates a config file at ~/.config/linelog/config.yaml when run for the first time. The default config contains what I think are sensible defaults, but if you disagree you're free to change almost all of the line counting behavior.

Config options take the form of regular expressions; when the program encounters a line that matches one of the expressions for a given filetype, it will not count it. See the comments in config.yaml for more details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linelog-1.0.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linelog-1.0.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file linelog-1.0.0.tar.gz.

File metadata

  • Download URL: linelog-1.0.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Linux/6.1.12-arch1-1

File hashes

Hashes for linelog-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f1a2f51f0f84807444413ea598ef465e28ba0c42e2b50fd2be741190bfad681b
MD5 30ba538d226fa24b736280af1ff9f68a
BLAKE2b-256 88922a022f6fc10a35d441a87ba42787532313d9863b03a072b284b9e1f87455

See more details on using hashes here.

File details

Details for the file linelog-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: linelog-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Linux/6.1.12-arch1-1

File hashes

Hashes for linelog-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e3af0ed8c54147f9fce12ff9fe6512fcefc48f41f87836d2f42ff398da75f51
MD5 420d4d6e6ebed8c49a27f59da71b7417
BLAKE2b-256 70a69630ccdebc51550ecc5c9b4ce48a616ada837d1fa0bbda3b3c9b75dd5f5f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

This release

1.0.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page