ruby / rake

A make-like build utility for Ruby.

Home Page:https://ruby.github.io/rake

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to approach adding logging timestamps

lzap opened this issue · comments

Hello,

our customer would like to have optional timestamps for rake output and I would like to contribute this feature if this is feasible. I did some research and it looks like both Rake codebase and Rakefiles use "Kernel.puts" directly. So I have two ideas I would like to discuss before I do any coding:

  1. Hacky approach: create STDOUT/STDERR wrappers and change $stdout and $stderr global variables to these instances. They would add timestamps when configured. Pros: Safe for the future changes because nothing is changing in the codebase. Cons: When Rake is used as a library, changing standard output and error would introduce regressions and problems after upgrade.

  2. Clean but disturbing approach: search and replace puts in the codebase and create a DSL method puts for use in Rakefiles. This looks cleaner, but developers are already used to puts in the codebase. Everytime new line with puts is added, the output will appear in the output without timestamp. Since this feature would be opt-in, devs will start adding these types kinds of errors pretty soon.

Honestly, I am not sure if I can deliver this feature to my customer but let's discuss and see what you guys think about this. Cheers!