replace echo with Log:: calls
authorChristian Weiske <cweiske@cweiske.de>
Tue, 13 Sep 2016 15:03:48 +0000 (17:03 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 13 Sep 2016 15:03:48 +0000 (17:03 +0200)
src/shpub/Cli.php
src/shpub/Command/Connect.php
src/shpub/Command/Like.php
src/shpub/Command/Note.php
src/shpub/Command/Reply.php
src/shpub/Command/Server.php
src/shpub/Log.php
src/shpub/Request.php

index 12eeaedecfdfb1c63b4e8caebee5ae492314de2d..30c2d1fd9f5be8c4b0b08d52e0bfb00991ad3e03 100644 (file)
@@ -41,7 +41,7 @@ class Cli
                 break;
             }
         } catch (\Exception $e) {
-            echo 'Error: ' . $e->getMessage() . "\n";
+            Log::err('Error: ' . $e->getMessage());
             exit(1);
         }
     }
index 668d7e90419a30c8001fe9f105fbfe7fd55889ee..2fd6d3800c4a11343d8c8118f6046164a5bac93a 100644 (file)
@@ -36,9 +36,10 @@ class Command_Connect
 
         list($redirect_uri, $socketStr) = $this->getHttpServerData();
         $state = time();
-        echo "To authenticate, open the following URL:\n"
+        Log::msg(
+            "To authenticate, open the following URL:\n"
             . $this->getBrowserAuthUrl($host, $user, $redirect_uri, $state)
-            . "\n";
+        );
 
         $authParams = $this->startHttpServer($socketStr);
         if ($authParams['state'] != $state) {
@@ -72,7 +73,7 @@ class Command_Connect
         }
         $this->cfg->hosts[$hostKey] = $host;
         $this->cfg->save();
-        echo "Server configuration $hostKey saved successfully.\n";
+        Log::info("Server configuration $hostKey saved successfully.");
     }
 
     protected function fetchAccessToken(
index fb396be6c7eaf93519d86373615ec8579da2c79a..5b456f955a56de5688d94af4e6051cf9d522b04d 100644 (file)
@@ -46,8 +46,8 @@ class Command_Like extends Command_AbstractProps
             Log::err($res->getBody());
             exit(20);
         } else {
-            echo "Like created at server\n";
-            echo $postUrl . "\n";
+            Log::info('Like created at server');
+            Log::msg($postUrl);
         }
     }
 }
index de6794890711f4d73fd9354c7583ff06370a683e..1ea599b57e847386d596ee149513e8fde61d5bd7 100644 (file)
@@ -36,8 +36,8 @@ class Command_Note extends Command_AbstractProps
 
         $res = $req->send();
         $postUrl = $res->getHeader('Location');
-        echo "Post created at server\n";
-        echo $postUrl . "\n";
+        Log::info('Post created at server');
+        Log::msg($postUrl);
     }
 }
 ?>
index e84a055f39d91d7fae1183b780500cf546ac7cce..b67d46b23b42bfdb7ee69671bee6d3f998b0f5af 100644 (file)
@@ -50,8 +50,8 @@ class Command_Reply extends Command_AbstractProps
         $res = $req->send();
 
         $postUrl = $res->getHeader('Location');
-        echo "Reply created at server\n";
-        echo $postUrl . "\n";
+        Log::info('Reply created at server');
+        Log::msg($postUrl);
     }
 }
 ?>
index 59843d4d33de1de36e9d857e8c1651ee6de3f2f3..8553414b214c9170f5e6daab9cd03d84313ed2bf 100644 (file)
@@ -11,10 +11,10 @@ class Command_Server
     public function run($verbose)
     {
         foreach ($this->cfg->hosts as $key => $host) {
-            echo $key . "\n";
+            Log::msg($key);
             if ($verbose) {
-                echo '  URL:  ' . $host->server . "\n";
-                echo '  User: ' . $host->user . "\n";
+                Log::msg('  URL:  ' . $host->server);
+                Log::msg('  User: ' . $host->user);
             }
         }
     }
index 99d9694909473df853671d893a47005564515b49..7b9dc719897f3259d2419e53e167a4d55a0f0c4d 100644 (file)
@@ -3,6 +3,16 @@ namespace shpub;
 
 class Log
 {
+    public static function info($msg)
+    {
+        echo $msg . "\n";
+    }
+
+    public static function msg($msg)
+    {
+        echo $msg . "\n";
+    }
+
     public static function err($msg)
     {
         file_put_contents('php://stderr', $msg . "\n", FILE_APPEND);
index 0924ddae1cf54ba725636b4294e336b2db895dc7..8ee7c5a25f15b37ace9527b15b15195a157267f0 100644 (file)
@@ -114,6 +114,6 @@ class Request
 
         $command .= ' ' . escapeshellarg((string) $this->req->getUrl());
 
-        echo $command . "\n";
+        Log::msg($command);
     }
 }
\ No newline at end of file