[Bps-public-commit] storage-box branch, fix-log-message-text, created. 9793bcc27dc7d1d0610e3bfacea58d0095533045

Dave Goehrig dave at bestpractical.com
Mon Sep 26 14:20:30 EDT 2016


The branch, fix-log-message-text has been created
        at  9793bcc27dc7d1d0610e3bfacea58d0095533045 (commit)

- Log -----------------------------------------------------------------
commit 9793bcc27dc7d1d0610e3bfacea58d0095533045
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Mon Sep 26 12:52:09 2016 -0400

    fix log message text expansions

diff --git a/META.json b/META.json
index 4337340..11ca7a5 100644
--- a/META.json
+++ b/META.json
@@ -55,7 +55,7 @@
       }
    },
    "release_status" : "stable",
-   "version" : "0.02",
+   "version" : "0.01",
    "x_contributors" : [
       "Dave Goehrig <dave at bestpractical.com>"
    ],
diff --git a/lib/Storage/Box.pm b/lib/Storage/Box.pm
index 1634505..913c1b7 100644
--- a/lib/Storage/Box.pm
+++ b/lib/Storage/Box.pm
@@ -95,7 +95,7 @@ sub authenticate_enterprise {
             client_secret => $self->client_secret
         ));
         my $req = $self->enterprise_auth->enterprise->request;
-        $logger->error("Failed to authenticate $self->enterprise_id with code $req->code\n") 
+        $logger->error("Failed to authenticate " . $self->enterprise_id . " with code " . $req->code . "\n") 
             unless $req->code == 200;
     }
     $self;
diff --git a/lib/Storage/Box/Auth.pm b/lib/Storage/Box/Auth.pm
index e829ac3..4bb2103 100644
--- a/lib/Storage/Box/Auth.pm
+++ b/lib/Storage/Box/Auth.pm
@@ -52,6 +52,7 @@ has user_id => '';                      # id of the user supplied by box.com
 has jwt => '';                          # JSON Web Token generated by user or enterprise
 has token => '';                        # OAuth2 token generated by request
 has expires => 0;
+has code => 0;
 
 =pod 
 
@@ -231,7 +232,13 @@ sub request {
     $curl->setopt(CURLOPT_FILE, \$body );
     $curl->setopt(CURLOPT_POSTFIELDS,$form);
     
-    return $self if ($curl->perform || $curl->getinfo(CURLINFO_RESPONSE_CODE) != 200 );
+    if ($curl->perform || $curl->getinfo(CURLINFO_RESPONSE_CODE) != 200 ) {
+        $self->code($curl->getinfo(CURLINFO_RESPONSE_CODE));
+        return $self 
+    }
+
+    $self->code($curl->getinfo(CURLINFO_RESPONSE_CODE));
+        
     my $res = decode_json $body;
     $self->expires(time + $res->{expires_in});
     $self->token($res->{access_token});
diff --git a/lib/Storage/Box/Request.pm b/lib/Storage/Box/Request.pm
index 3394b11..a76950a 100644
--- a/lib/Storage/Box/Request.pm
+++ b/lib/Storage/Box/Request.pm
@@ -41,7 +41,7 @@ our $logger = Storage::Box::Logger::logger;
 sub get {
     my $self = shift;
     $self->curl( WWW::Curl::Easy->new() ) unless $self->curl;
-    $logger->debug("GET $self->url\n");
+    $logger->debug("GET " . $self->url . "\n");
     $self;
 }
 
@@ -49,7 +49,7 @@ sub post {
     my $self = shift;
     $self->curl( WWW::Curl::Easy->new() ) unless $self->curl;
     $self->curl->setopt(CURLOPT_POST, 1);
-    $logger->debug("POST $self->url\n");
+    $logger->debug("POST " . $self->url . "\n");
     $self;
 }
 
@@ -57,7 +57,7 @@ sub put {
     my $self = shift;
     $self->curl( WWW::Curl::Easy->new() ) unless $self->curl;
     $self->curl->setopt(CURLOPT_CUSTOMREQUEST,"PUT");
-    $logger->debug("PUT $self->url\n");
+    $logger->debug("PUT " . $self->url . "\n");
     $self;
 }
 
@@ -65,7 +65,7 @@ sub delete {
     my $self = shift;
     $self->curl( WWW::Curl::Easy->new() ) unless $self->curl;
     $self->curl->setopt(CURLOPT_CUSTOMREQUEST,"DELETE");
-    $logger->debug("DELETE $self->url\n");
+    $logger->debug("DELETE " . $self->url . "\n");
     $self;
 }
 
@@ -73,7 +73,7 @@ sub request {
     my $self = shift;
     $self->curl( WWW::Curl::Easy->new() ) unless $self->curl;
     my $auth = $self->auth->token();
-    $self->warn("No authorization token for request $self->url") unless $auth;
+    $self->warn("No authorization token for request " . $self->url) unless $auth;
     my $headers = [
         "Accept: */*",
         "Authorization: Bearer " . $auth
@@ -85,20 +85,20 @@ sub request {
     $self->curl->setopt(CURLOPT_URL,$self->url);
     $self->curl->setopt(CURLOPT_HTTPPOST,$self->form) if ($self->form ne ''); 
     if ($self->curl->perform) {  # CURLE_OK is 0
-        $logger->warn("Curl to $self->url failed, retrying $self->retries\n");
+        $logger->warn("Curl to " . $self->url . " failed, retrying  " . $self->retries . "\n");
         if ( ++$self->retries < $self->max_retries) {
             sleep 1;
             return $self->request;
         }
-        $logger->error("Curl exceeded max tries to $self->url\n");
+        $logger->error("Curl exceeded max tries to " . $self->url . "\n");
         $self->retries(0);
         $self->body('');    # fail with empty body
         return $self;
     }
     $self->code($self->curl->getinfo(CURLINFO_RESPONSE_CODE));
-    $logger->info("Request to $self->url returned status $self->code\n");
+    $logger->info("Request to " . $self->url . " returned status  " . $self->code . "\n");
     $self->body($body);
-    $logger->debug("Response: $self->body\n");
+    $logger->debug("Response: " . $self->body . "\n");
     $self;
 }
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list