second version using std io buffer to log