Smarter logging