Cleanups to reactive logging code for R CMD check

These are some fixes to make R CMD check happy. @trestletech, could you review and test it? (I'm not sure how to test this code).

Changes: 

* Fix 'env' partial argument match for get().
* Fix access of unbound global variable `.shiny__stdout`.
* Restructure if statement so test is only done once. This wasn't necessary for R CMD check, but given the other changes (setting the `shiny_stdout` var), this reduced code duplication.