in reply to Capturing Text from a die command

Are you sure you want to write your own logger? The Log::Log4perl package provides everything you can probably think of, including your requirement. Check for logdie() in the documentation.