File tree Expand file tree Collapse file tree 5 files changed +67
-2
lines changed Expand file tree Collapse file tree 5 files changed +67
-2
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased  
44
5+ ### Added  
6+ *  It is now possible to log HTTP requests and responses to the Firebase APIs to existing log channels. 
7+   See the "logging" section in [ ` config/firebase.php ` ] ( config/firebase.php )  for the configuration 
8+   options and the [ SDK Logging Documentation] ( https://firebase-php.readthedocs.io/en/5.5.0/setup.html#logging )  
9+   for more information.
10+ ### Changed  
511*  The default branch of the GitHub repository has been renamed from ` master `  to ` main `  - 
612  if you're using ` dev-master `  as a version constraint in your ` composer.json ` , please 
713  update it to ` dev-main ` .
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ FIREBASE_CREDENTIALS=relative/path/to/firebase_credentials.json
7373``` 
7474
7575For further configuration, please see [ config/firebase.php] ( config/firebase.php ) . You can modify the configuration
76- by copying it to your local ` config `  directory:
76+ by copying it to your local ` config `  directory or by defining the environment variables used in the config file :
7777
7878``` bash 
7979#  Laravel
Original file line number Diff line number Diff line change 113113
114114    /** 
115115     * ------------------------------------------------------------------------ 
116-      * Debug 
116+      * Logging 
117+      * ------------------------------------------------------------------------ 
118+      * 
119+      * Enable logging of HTTP interaction for insights and/or debugging. 
120+      * 
121+      * Log channels are defined in config/logging.php 
122+      * 
123+      * Successful HTTP messages are logged with the log level 'info'. 
124+      * Failed HTTP messages are logged with the the log level 'notice'. 
125+      * 
126+      * Note: Using the same channel for simple and debug logs will result in 
127+      * two entries per request and response. 
128+      */ 
129+ 
130+     'logging '  => [
131+         'http_log_channel '  => env ('FIREBASE_HTTP_LOG_CHANNEL ' , null ),
132+         'http_debug_log_channel '  => env ('FIREBASE_HTTP_DEBUG_LOG_CHANNEL ' , null ),
133+     ],
134+ 
135+     /** 
136+      * ------------------------------------------------------------------------ 
137+      * Debug (deprecated) 
117138     * ------------------------------------------------------------------------ 
118139     * 
119140     * Enable debugging of HTTP requests made directly from the SDK. 
Original file line number Diff line number Diff line change @@ -117,6 +117,18 @@ private function registerFactory(): void
117117                );
118118            }
119119
120+             if  ($ logChannel  = $ config ['logging ' ]['http_log_channel ' ] ?? null ) {
121+                 $ factory  = $ factory ->withHttpLogger (
122+                     $ app ->make ('log ' )->channel ($ logChannel )
123+                 );
124+             }
125+ 
126+             if  ($ logChannel  = $ config ['logging ' ]['http_debug_log_channel ' ] ?? null ) {
127+                 $ factory  = $ factory ->withHttpDebugLogger (
128+                     $ app ->make ('log ' )->channel ($ logChannel )
129+                 );
130+             }
131+ 
120132            return  $ factory ;
121133        });
122134    }
Original file line number Diff line number Diff line change @@ -117,6 +117,32 @@ public function the_storage_default_bucket_can_be_configured(): void
117117        $ this  ->assertSame ($ name , $ property ->getValue ($ storage ));
118118    }
119119
120+     /** @test */ 
121+     public  function  logging_can_be_configured (): void 
122+     {
123+         $ this  ->app ->config ->set ('firebase.logging.http_log_channel ' , 'stack ' );
124+ 
125+         $ factory  = $ this  ->app ->make (Firebase \Factory::class);
126+ 
127+         $ property  = ReflectionObject::createFromInstance ($ factory )->getProperty ('httpLogMiddleware ' );
128+         $ property ->setVisibility (\ReflectionProperty::IS_PUBLIC );
129+ 
130+         $ this  ->assertNotNull ($ property ->getValue ($ factory ));
131+     }
132+ 
133+     /** @test */ 
134+     public  function  debug_logging_can_be_configured (): void 
135+     {
136+         $ this  ->app ->config ->set ('firebase.logging.http_debug_log_channel ' , 'stack ' );
137+ 
138+         $ factory  = $ this  ->app ->make (Firebase \Factory::class);
139+ 
140+         $ property  = ReflectionObject::createFromInstance ($ factory )->getProperty ('httpDebugLogMiddleware ' );
141+         $ property ->setVisibility (\ReflectionProperty::IS_PUBLIC );
142+ 
143+         $ this  ->assertNotNull ($ property ->getValue ($ factory ));
144+     }
145+ 
120146    /** @test */ 
121147    public  function  it_uses_the_laravel_cache (): void 
122148    {
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments