smarter logging with fallback to console.log