The Rub

Automatically Simple Since 2002

Simple Python Note and Time Logger

15 April 2010

At my job we used to have to have to log every hour worked.  I really hated it at first, but I got used to it.  After a while, I took for granted the ability to look back to see what I did on any given day.  Recently, they changed the policy so that we no longer have to log all of our hours, and I immediately began to lose track of my work history.

My solution is very simple.  Since I always have many terminals and screens running, I figured it would be nice if I could just leave notes for myself.  Here’s what I did:

#!/usr/bin/env python
from datetime import datetime

def log(msg):
    if len(msg)<2:
        return

    f = open('work.log', 'a')
    now = datetime.now().strftime("%Y-%m-%d %H:%M")
    f.write("%s: %s\n" % (now, msg))
    print "%s: %s" % (now, msg)
    f.close()

while(True):
    log(raw_input('work? '))

I simply run it in a terminal screen and whenever I’m working on something or complete something I jot down a note to myself.

Likewise, I did the same thing but for general notes. I generally use a wiki for note taking. The trouble is, the model doesn’t work very well for me for transient and petty things. This way, I can just paste/type whatever I’d like into my note file and not really worry about publishing or styling or anything.

The method has yet to prove itself, and it is extremely rudimentary. I prefer to start as simple as possible and grow organically instead of attempting to construct a large solution that may or may not be used as anticipated (even by myself).