Context-aware logging