content/articles/redbook.textile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
----- permalink: redbook filters_pre: - redcloth title: RedBook - A simple Ruby program for your daily logging needs comments: - :date: 2007-09-30 06:16:02 +02:00 :author: David Cumps :url: http://blog.cumps.be :id: 92 :body: |- I've always wondered, what do you log in these systems? I already log most of my time at work in timetracking systems, that I couldn't imagine logging spare time, what's going to be the benefit? Ofcourse, a script like this instead of some bloated time tracking system which has a GUI that makes you take ages for inputting something. - :date: 2007-09-30 06:48:48 +02:00 :author: Fabio Cevasco :url: http://www.h3rald.com :id: 93 :body: "We have a time tracking system at work, but I normally tend to use it once a day... I use this script everyday to quickly keep track of what I'm doing _while_ I'm doing it, rather than trying to remember it afterwards ;-) " - :date: 2007-10-01 03:43:18 +02:00 :author: bryan :url: "" :id: 94 :body: | pretty cool.. any idea how to make backspace/delete work correctly on a mac? Im suffering from ^H disease. :) - :date: 2007-10-01 05:06:28 +02:00 :author: Fabio Cevasco :url: http://www.h3rald.com :id: 95 :body: |- @bryan Thanks for pointing it out. I'm looking into it, although I think to fix that I'll have to use either the Curses or Readline libraries, and I was trying to avoid it... I'll have a look (suggestions are welcome of course!) - :date: 2007-10-01 05:17:20 +02:00 :author: Viktor Nordling :url: "" :id: 96 :body: |- Looks neat! I think it would be a perfect plugin for Launchy: (http://www.launchy.net/). Then I could just hit alt+space, write log | message and move on! For similar plugins for Launchy, please see: http://todoist.com/Help/viewLaunchy/ Cheers, Viktor Nordling - :date: 2007-10-01 12:40:28 +02:00 :author: Dharivs :url: "" :id: 97 :body: |- Nice! You are my God! I was just about to implement it, but I couldn't... Thanks a lot :) - :date: 2007-10-02 14:46:13 +02:00 :author: bryan :url: "" :id: 98 :body: | Fabio: I'm afraid I've never used those libraries myself.. I'm a web guy, don't get into the command line stuff much.. but I'll keep checking back to see if you or anyone else does anything with it.. I think this looks like a nice logger tool. :) - :date: 2007-10-02 15:27:01 +02:00 :author: Fabio Cevasco :url: http://www.h3rald.com :id: 99 :body: I scheduled key bindings and support for international characters for the "1.0" release... Or hopefully before, you never know! I'm also trying to plan a few "milestones":http://www.assembla.com/spaces/milestones/index/bWE7NkzCqr3k25abIlDkbG?spaces_tool_id=ceS8UazCqr3k25abIlDkbG. - :date: 2007-10-19 06:27:29 +02:00 :author: James O'Kelly :url: "" :id: 103 :body: I'll be trying RedBook out, thanks for the tip Fabio! And I totally agree about the command line, and Quicksilver is just crazy sexy. I don't even remember how to use my launcher anymore :) - :date: 2007-10-20 03:44:09 +02:00 :author: Fabio Cevasco :url: http://www.h3rald.com :id: 104 :body: "Hello James, thanks. Well, actually next week I'll probably release v0.3, which comes with Readline support (which means history and proper key bindings for mac/*nix users) and quite a few new features. \n\ By the way, I don't seem to be able to find your email address anywhere... " - :date: 2008-03-12 17:52:49 +01:00 :author: mrnovell.com :url: "" :id: 216 :body: This is great, I am going to have my IT team start using it. Will there be a feature to where we can have central logging. date: 2007-09-29 14:05:00 +02:00 tags: - ruby - productivity - software - tools - redbook type: article toc: true ----- 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: * "QuickLogger":http://lifehacker.com/software/top/geek-to-live--quick+log-your-work-day-189772.php * "Life Logger":http://lifehacker.com/software/windows/log-your-workday-from-the-system-tray-with-life-logger-285602.php * "QuickLogger 2":http://lifehacker.com/software/featured-windows-download/log-your-workday-with-quicklogger-2-302932.php 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":http://www.assembla.com/space/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. h3. 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":http://www.tiddlywiki.com) file provided with the program or "browse it online":http://redbook.h3rald.com. 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... h3. 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":http://www.assembla.com/spaces/files/redbook). Here's what happens when you start the program: <span style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New'; font-size: 10px"> ---<br /> RedBook v0.1 - Copyright (c) 2007, Fabio Cevasco<br /> ---<br /> <span style="color:blue">>></span> Loading config file...<br /> <span style="color:green">>></span> Config file loaded.<br /> <span style="color:blue">>></span> Loading log file...<br /> <span style="color:green">>></span> Log file loaded.<br /> <span style="color:blue">>></span> Ready.<br /> <span style="color:red">Red</span>Book >><br /> </code> </span> 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: <span style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New'; font-size: 10px"> <span style="color:red">Red</span>Book >> :log My first message :tags test<br /> <span style="color:green">>></span> Logged.<br /> <span style="color:red">Red</span>Book >> :log This is another message<br /> <span style="color:green">>></span> Logged.<br /> <span style="color:red">Red</span>Book >> :log This is another message :tags test another_test<br /> <span style="color:green">>></span> Logged.<br /> </span> 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: <span style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New'; font-size: 10px"> <span style="color:red">Red</span>Book >> :select<br /> <span style="color:yellow">1</span> <span style="color:blue">Sat Sep 29 2007 - 09:09:32 PM</span> My first message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><br /> <span style="color:yellow">2</span> <span style="color:blue">Sat Sep 29 2007 - 09:10:51 PM</span> This is another message<br /> <span style="color:yellow">3</span> <span style="color:blue">Sat Sep 29 2007 - 09:11:45 PM</span> This is another message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><span style="color:cyan">[</span><span style="color:yellow">another_test</span><span style="color:cyan">]</span><br /> <span style="color:green">>></span> 3 messages loaded.<br /> </span> 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: <span style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New'; font-size: 10px"> <span style="color:red">Red</span>Book >> :select :tags test<br /> <span style="color:yellow">1</span> <span style="color:blue">Sat Sep 29 2007 - 09:09:32 PM</span> My first message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><br /> <span style="color:yellow">3</span> <span style="color:blue">Sat Sep 29 2007 - 09:11:45 PM</span> This is another message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><span style="color:cyan">[</span><span style="color:yellow">another_test</span><span style="color:cyan">]</span><br /> <span style="color:green">>></span> 2 messages loaded.<br /> </span> 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":http://chronic.rubyforge.org/ 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: <span style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New'; font-size: 10px"> <span style="color:red">Red</span>Book >> :calc 1 3<br /> <span style="color:yellow">1</span> <span style="color:blue">Sat Sep 29 2007 - 09:09:32 PM</span> My first message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><br /> --- 2 minutes and 13 seconds.<br /> <span style="color:yellow">3</span> <span style="color:blue">Sat Sep 29 2007 - 09:11:45 PM</span> This is another message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><span style="color:cyan">[</span><span style="color:yellow">another_test</span><span style="color:cyan">]</span><br /> </span> Similarly, if no IDs are specified, :calc calculates the time difference between each message and the previous: <span style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New'; font-size: 10px"> <span style="color:red">Red</span>Book >> :calc<br /> <span style="color:yellow">1</span> <span style="color:blue">Sat Sep 29 2007 - 09:09:32 PM</span> My first message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><br /> --- 1 minute and 19 seconds.<br /> <span style="color:yellow">2</span> <span style="color:blue">Sat Sep 29 2007 - 09:10:51 PM</span> This is another message<br /> --- 54 seconds.<br /> <span style="color:yellow">3</span> <span style="color:blue">Sat Sep 29 2007 - 09:11:45 PM</span> This is another message <span style="color:cyan">[</span><span style="color:yellow">test</span><span style="color:cyan">]</span><span style="color:cyan">[</span><span style="color:yellow">another_test</span><span style="color:cyan">]</span><br /> </span> Finally, you can save loaded messages to a TXT, YAML or CSV file, as follows: <span style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New'; font-size: 10px"> <span style="color:red">Red</span>Book >> :save log.txt<br /> <span style="color:blue">>></span> Saving...<br /> <span style="color:green">>></span> Saved dataset to "log.txt"<br /> </span> 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. h3. 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! p=. "Home Page":http://redbook.h3rald.com | "Development":http://code.google.com/p/redbook/ | "Download":http://code.google.com/p/redbook/downloads/list |