Browse Source

add log in start and end

visuddhinanda 2 years ago
parent
commit
39f9cf5a85

+ 3 - 1
app/Console/Commands/ExportChannel.php

@@ -42,7 +42,8 @@ class ExportChannel extends Command
      */
     public function handle()
     {
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        Log::debug('task export offline channel-table start');
+        $exportFile = storage_path('app/public/export/offline/wikipali-offline-'.date("Y-m-d").'.db3');
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
@@ -77,6 +78,7 @@ class ExportChannel extends Command
         }
         $dbh->commit();
         $bar->finish();
+        Log::debug('task export offline channel-table finished');
         return 0;
     }
 }

+ 2 - 0
app/Console/Commands/ExportChapter.php

@@ -46,6 +46,7 @@ class ExportChapter extends Command
      */
     public function handle()
     {
+        Log::debug('task export offline chapter-table start');
         $book = $this->argument('book');
         $para = $this->argument('para');
         $channelId = $this->argument('channel');
@@ -172,6 +173,7 @@ class ExportChapter extends Command
             $this->error($data['code'].'-'.$data['message']);
         }
 
+        Log::debug('task export offline chapter-table finished');
         return 0;
     }
 }

+ 3 - 1
app/Console/Commands/ExportChapterIndex.php

@@ -42,7 +42,8 @@ class ExportChapterIndex extends Command
      */
     public function handle()
     {
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        Log::debug('task export offline chapter-index-table start');
+        $exportFile = storage_path('app/public/export/offline/wikipali-offline-'.date("Y-m-d").'.db3');
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
@@ -80,6 +81,7 @@ class ExportChapterIndex extends Command
         }
         $dbh->commit();
         $bar->finish();
+        Log::debug('task export offline chapter-index-table finished');
         return 0;
     }
 }

+ 4 - 1
app/Console/Commands/ExportCreateDb.php

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Facades\Log;
 
 class ExportCreateDb extends Command
 {
@@ -38,9 +39,10 @@ class ExportCreateDb extends Command
      */
     public function handle()
     {
+        Log::debug('task export offline create-db start');
         $sqlPath = database_path('export/sentence.sql');
         $exportDir = storage_path('app/public/export/offline');
-        $exportFile = $exportDir.'/sentence-'.date("Y-m-d").'.db3';
+        $exportFile = $exportDir.'/wikipali-offline-'.date("Y-m-d").'.db3';
         $file = fopen($exportFile,'w');
         fclose($file);
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
@@ -52,6 +54,7 @@ class ExportCreateDb extends Command
         foreach ($_arr as $_value) {
             $dbh->query($_value . ';');
         }
+        Log::debug('task export offline create-db finished');
         return 0;
     }
 }

+ 8 - 0
app/Console/Commands/ExportOffline.php

@@ -5,6 +5,7 @@ namespace App\Console\Commands;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Log;
 
 class ExportOffline extends Command
 {
@@ -62,6 +63,7 @@ class ExportOffline extends Command
         //导出channel
         $this->info('channel');
         $this->call('export:channel');
+        
         //tag
         $this->info('tag');
         $this->call('export:tag');
@@ -80,8 +82,14 @@ class ExportOffline extends Command
         $this->call('export:sentence',['--type'=>'original']);
 
         $this->info('zip');
+        
         $exportPath = 'app/public/export/offline';
         $exportFile = 'wikipali-offline-'.date("Y-m-d").'.db3';
+        Log::debug('zip db file {filename} {format}',
+                    [
+                        'filename'=>$exportFile,
+                        'format'=>$this->argument('format')
+                    ]);
         switch ($this->argument('format')) {
             case '7z':
                 $zipFile = $exportFile . ".7z";

+ 4 - 1
app/Console/Commands/ExportPalitext.php

@@ -40,7 +40,9 @@ class ExportPalitext extends Command
      */
     public function handle()
     {
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        Log::debug('task export offline palitext-table start');
+
+        $exportFile = storage_path('app/public/export/offline/wikipali-offline-'.date("Y-m-d").'.db3');
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
@@ -76,6 +78,7 @@ class ExportPalitext extends Command
         }
         $dbh->commit();
         $bar->finish();
+        Log::debug('task: export offline palitext-table finished');
 
         return 0;
     }

+ 3 - 1
app/Console/Commands/ExportSentence.php

@@ -44,6 +44,7 @@ class ExportSentence extends Command
      */
     public function handle()
     {
+        Log::debug('task export offline sentence-table start');
         $channels = [];
         $channel_id = $this->option('channel');
         if($channel_id){
@@ -68,7 +69,7 @@ class ExportSentence extends Command
         }
 
 
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        $exportFile = storage_path('app/public/export/offline/wikipali-offline-'.date("Y-m-d").'.db3');
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
@@ -120,6 +121,7 @@ class ExportSentence extends Command
         }
         $dbh->commit();
         $bar->finish();
+        Log::debug('task export sentence finished');
         return 0;
     }
 }

+ 5 - 1
app/Console/Commands/ExportTag.php

@@ -40,7 +40,9 @@ class ExportTag extends Command
      */
     public function handle()
     {
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        Log::debug('task: export offline data tag-table start');
+
+        $exportFile = storage_path('app/public/export/offline/wikipali-offline-'.date("Y-m-d").'.db3');
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
@@ -69,6 +71,8 @@ class ExportTag extends Command
         }
         $dbh->commit();
         $bar->finish();
+        Log::debug('task: export offline data tag-table start');
+
         return 0;
     }
 }

+ 3 - 1
app/Console/Commands/ExportTagmap.php

@@ -40,7 +40,8 @@ class ExportTagmap extends Command
      */
     public function handle()
     {
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        Log::debug('task: export offline tagmap-table start');
+        $exportFile = storage_path('app/public/export/offline/wikipali-offline-'.date("Y-m-d").'.db3');
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
@@ -65,6 +66,7 @@ class ExportTagmap extends Command
         }
         $dbh->commit();
         $bar->finish();
+        Log::debug('task: export offline tagmap-table finished');
         return 0;
     }
 }

+ 3 - 1
app/Console/Commands/ExportTerm.php

@@ -40,7 +40,8 @@ class ExportTerm extends Command
      */
     public function handle()
     {
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        Log::debug('task export offline term-table start');
+        $exportFile = storage_path('app/public/export/offline/wikipali-offline-'.date("Y-m-d").'.db3');
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
@@ -88,6 +89,7 @@ class ExportTerm extends Command
         }
         $dbh->commit();
         $bar->finish();
+        Log::debug('task export offline term-table finished');
         return 0;
     }
 }