Give developers instantaneous logging feedback

I worked at a company that, for security reasons, did not give developers direct access to the logs for the applications they deployed.  Instead, developers had access to a 3rd party app that conglomerated all the logs of all the applications of all of the environments.  If you can see logs for your actions as soon as they occur, then there’s nothing wrong with this.  The problem was that this 3rd party app would become a bottleneck that all logs had to go through.  As a result, there could be up to a 30 minute delay for some logs.

Continue reading

If you’re having trouble testing legacy code, mock a logger

I was working on some legacy code (“legacy” meaning it has no automated test coverage) and I really wanted to write some automated acceptance tests for it.  The problem is, I could not think of a way to do that without refactoring the code first.  I did not want to do this because “it was already working” and the refactoring could have introduced new bugs.  I had a chicken and egg problem: I didn’t want to modify code until I had automated tests but I had to modify code to write the automated tests.  Which comes first?

I ended up using a trick that minimally changes the production code, actually improves the production code base, and allows me to write automated tests.  It’s these two simple steps:

Continue reading