<?php
use Codeception\Extension\Logger;
if ($scenario->running()) {
Logger::log((string)$var);
}
?>
please, do see docs
and regarding seeing variable value, the preferable way is typecasting to string if it's a scalar data, accessing array index/key if it's an array, etc. but there is undocumented method $var->__value() which you can use for debugging, but should not rely on it in tests