Logging your daily activities is important. If you don't believe me you'd better check at least these three posts on LifeHacker, which feature different scripts and applications:
I had a look at each one of them, and I believe they are quite useful, although I didn't really find what I was looking for. Why? Well, for example:
- I don't believe a GUI is necessary — you'd better off with just a shortcut key or command to run from Launchy or QuickSilver, that's much faster.
- They just log timestamped messages on a file, there's no real way to search through them and display them except by using a test editor
- They are Windows only — not that it matters for me, but others may not be happy about it.
That's why I thought I'd roll out my own: meet RedBook.
Let me say it's nothing fancy: I'm not a full-time programmer but I do like playing with Ruby during my lunch breaks
at work, so that's why RedBook is just a humble, tiny Ruby script. This automatically makes it cross-platform: you
can install Ruby very easily on Linux & alikes, Mac OS X and Windows. Furthermore, if you are on Windows and for
some weird reason you don't want to install Ruby, you can just try out the packed EXE file
(made with RubyScript2Exe) — it's about 2MB, but you won't need anything else.
How It Works ⇈
The program uses two YAML files, one for configuration, which must reside in the same directory as redbook.rb (or redboo.exe) and one for the log itself, which you can place anywhere, provided that you edit the configuration file accordingly. For information on how to install RedBook and how to configure it, you can check the manual.html (powered by TiddlyWiki) file provided with the program or browse it online.
When started, RedBook will load both the configuration file (config.yml) and the whole log file into memory — it's not a big deal, considering that they are only text files after all. I did a test with a log of quite a few MBs, and it was fine.
You can then start input commands right away, following a few sample rules. RedBook has a (very) rudimentary parser which is able to detect keywords, i.e. alphabetic strings prepended with a colon. RedBook commands look like this:
- :log This message will be logger :tags tag1 tag2
- :select :last 15 :since January
- :save /home/h3rald/backup.yml
If everything goes OK, RedBook will reply with some sort of response, an acknowledgement, a list of messages, etc.
Simple.
Here's basically what the program can do:
- Log any message to the main log file. Messages can be tagged with one or more tags and will be automatically timestamped.
- Load/display a list of logged messages on the screen. It is possible to filter messages by specifying a time span, a string to search in the message text, or a list of tags.
- Dump loaded messages to a TXT, CSV or YAML file (you can even backup your log saving it to another YAML file in this way).
- Calculate the time elapsed between two or more tasks. Time will be displayed in years, months, weeks, days, hours, minutes and/or seconds as necessary.
How? Here's a short tutorial…
A Quick RedBook Tutorial ⇈
Let's assume you are able to run RedBook on your system by now (if you can't find some of the gems which are required for it, you can download them packed in a ZIP file from here).
Here's what happens when you start the program:
-
RedBook v0.1 – Copyright © 2007, Fabio Cevasco
-
>> Loading config file…
>> Config file loaded.
>> Loading log file…
>> Log file loaded.
>> Ready.
RedBook >>
Good. Let's start logging something then. Just use the :log keyword, followed by a message, and then you can also add the :tags keyword followed by space-separated tags, like this:
RedBook >> :log My first message :tags test
>> Logged.
RedBook >> :log This is another message
>> Logged.
RedBook >> :log This is another message :tags test
another_test
>> Logged.
Try waiting a few seconds between each message. These three messages will be appended to the log file. You could open it in an editor, but it's normally easier to display them directly inside RedBook, like this:
RedBook >> :select
1 Sat Sep 29 2007 – 09:09:32 PM My first
message [test]
2 Sat Sep 29 2007 – 09:10:51 PM This is
another message
3 Sat Sep 29 2007 – 09:11:45 PM This is
another message [test][another_test]
>> 3 messages loaded.
Easy. What if you have hundreds of messages? Well, the :select operation can take an optional search string, or you can tell RedBook to load only those messages tagged with one or more specific tags, like this:
RedBook >> :select :tags test
1 Sat Sep 29 2007 – 09:09:32 PM My first
message [test]
3 Sat Sep 29 2007 – 09:11:45 PM This is
another message [test][another_test]
>> 2 messages loaded.
Or you can use the :from and/or :to keywords to specify a certain time frame, like this:
:select :tags test :from ten minutes ago
:select :from last week :to 2 days ago
RedBook includes a very nice “natural language date/time parser”, Chronic which is able to convert sentences like the following into Ruby Time objects:
- 6 in the morning
- friday 1pm
- sat 7 in the evening
- today
- yesterday at 4:00
It's not perfect (and it's in pre-alpha as well), but it does the job, for what I can see, and it makes it very easy and fast to specify timeframes.
After executing a :select command, two other operations can be performed on the loaded messages: :calc and :save.
:calc calculates the exact amount of time elapsed between two or more tasks. Do you remember the numbers on the far left of each message? Think them as temporary IDs for the actual messages, and you can use them to select specific tasks when executing the :calc operation:
RedBook >> :calc 1 3
1 Sat Sep 29 2007 – 09:09:32 PM My first
message [test]
- 2 minutes and 13 seconds.
3 Sat Sep 29 2007 – 09:11:45 PM This is
another message [test][another_test]
Similarly, if no IDs are specified, :calc calculates the time difference between each message and the previous:
RedBook >> :calc
1 Sat Sep 29 2007 – 09:09:32 PM My first
message [test]
- 1 minute and 19 seconds.
2 Sat Sep 29 2007 – 09:10:51 PM This is
another message
- 54 seconds.
3 Sat Sep 29 2007 – 09:11:45 PM This is
another message [test][another_test]
Finally, you can save loaded messages to a TXT, YAML or CSV file, as follows:
RedBook >> :save log.txt
>> Saving…
>> Saved dataset to “log.txt”
h
If you want to backup your log, you can load all messages and then save them to a YAML
file. Maybe in this case you want to append the :silent keyword to the :select command, so
that messages won't be displayed on the screen.
Conclusion ⇈
RedBook is just a simple program: it suits my needs for now, but of course there's roo for improvement. If you have some useful suggestions, or you want to contribute in some way, feel free to contact me!