diff --git a/src/Auth/User.php b/src/Auth/User.php index d0fd95d..882e69e 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -83,4 +83,14 @@ class User { ); } + /** + * Magic method to allow pretty cast to string + * @return string + */ + public function __toString() { + if (isset($this -> name)) + return sprintf('%s (%s)', $this -> name, $this -> username); + return $this -> namename; + } + } diff --git a/src/Log.php b/src/Log.php index 2ed71a2..fc98729 100644 --- a/src/Log.php +++ b/src/Log.php @@ -163,7 +163,7 @@ class Log { $_SERVER['REMOTE_ADDR'], ); if (Auth::enabled()) - $msg[] = (Auth::user()?Auth::user()->username:'anonymous'); + $msg[] = (Auth::user()?Auth::user():'anonymous'); $msg[] = $level; $msg[] = $message; $msg = implode(' - ', $msg)."\n";