Improved logging functions