@@ -77,6 +77,7 @@ Vector<BaseString> g_include_databases, g_exclude_databases;
77
77
Properties g_rewrite_databases;
78
78
NdbRecordPrintFormat g_ndbrecord_print_format;
79
79
unsigned int opt_no_binlog;
80
+ static bool opt_timestamp_printouts;
80
81
81
82
class RestoreOption
82
83
{
@@ -146,6 +147,10 @@ static bool opt_restore_privilege_tables = false;
146
147
static struct my_option my_long_options[] =
147
148
{
148
149
NDB_STD_OPTS (" ndb_restore" ),
150
+ { " timestamp_printouts" , NDB_OPT_NOSHORT,
151
+ " Add a timestamp to the logger messages info, error and debug" ,
152
+ (uchar**) &opt_timestamp_printouts, (uchar**) &opt_timestamp_printouts, 0 ,
153
+ GET_BOOL, NO_ARG, false , 0 , 0 , 0 , 0 , 0 },
149
154
{ " connect" , ' c' , " same as --connect-string" ,
150
155
(uchar**) &opt_ndb_connectstring, (uchar**) &opt_ndb_connectstring, 0 ,
151
156
GET_STR, REQUIRED_ARG, 0 , 0 , 0 , 0 , 0 , 0 },
@@ -603,6 +608,9 @@ readArguments(int *pargc, char*** pargv)
603
608
{
604
609
exit (NdbRestoreStatus::WrongArgs);
605
610
}
611
+ if (opt_timestamp_printouts) {
612
+ restoreLogger.set_print_timestamp (true );
613
+ }
606
614
if (ga_nodeId == 0 )
607
615
{
608
616
err << " Backup file node ID not specified, please provide --nodeid" << endl;
@@ -1320,8 +1328,6 @@ main(int argc, char** argv)
1320
1328
1321
1329
init_progress ();
1322
1330
1323
- char timestamp[64 ];
1324
-
1325
1331
/* *
1326
1332
* we must always load meta data, even if we will only print it to stdout
1327
1333
*/
@@ -1336,8 +1342,7 @@ main(int argc, char** argv)
1336
1342
}
1337
1343
#endif
1338
1344
1339
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1340
- restoreLogger.log_info (" %s [restore_metadata] Read meta data file header" , timestamp);
1345
+ restoreLogger.log_info (" [restore_metadata] Read meta data file header" );
1341
1346
1342
1347
if (!metaData.readHeader ())
1343
1348
{
@@ -1390,8 +1395,7 @@ main(int argc, char** argv)
1390
1395
}
1391
1396
1392
1397
restoreLogger.log_debug (" Load content" );
1393
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1394
- restoreLogger.log_info (" %s [restore_metadata] Load content" , timestamp);
1398
+ restoreLogger.log_info (" [restore_metadata] Load content" );
1395
1399
1396
1400
int res = metaData.loadContent ();
1397
1401
@@ -1404,8 +1408,7 @@ main(int argc, char** argv)
1404
1408
exitHandler (NdbRestoreStatus::Failed);
1405
1409
}
1406
1410
restoreLogger.log_debug (" Get number of Tables" );
1407
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1408
- restoreLogger.log_info (" %s [restore_metadata] Get number of Tables" , timestamp);
1411
+ restoreLogger.log_info (" [restore_metadata] Get number of Tables" );
1409
1412
if (metaData.getNoOfTables () == 0 )
1410
1413
{
1411
1414
restoreLogger.log_error (" The backup contains no tables" );
@@ -1453,8 +1456,7 @@ main(int argc, char** argv)
1453
1456
}
1454
1457
1455
1458
restoreLogger.log_debug (" Validate Footer" );
1456
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1457
- restoreLogger.log_info (" %s [restore_metadata] Validate Footer" , timestamp);
1459
+ restoreLogger.log_info (" [restore_metadata] Validate Footer" );
1458
1460
1459
1461
if (!metaData.validateFooter ())
1460
1462
{
@@ -1481,8 +1483,7 @@ main(int argc, char** argv)
1481
1483
g_consumers[i]->report_started (ga_backupId, ga_nodeId);
1482
1484
1483
1485
restoreLogger.log_debug (" Restore objects (tablespaces, ..)" );
1484
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1485
- restoreLogger.log_info (" %s [restore_metadata] Restore objects (tablespaces, ..)" , timestamp);
1486
+ restoreLogger.log_info (" [restore_metadata] Restore objects (tablespaces, ..)" );
1486
1487
for (i = 0 ; i<metaData.getNoOfObjects (); i++)
1487
1488
{
1488
1489
for (Uint32 j= 0 ; j < g_consumers.size (); j++)
@@ -1504,8 +1505,7 @@ main(int argc, char** argv)
1504
1505
1505
1506
Vector<OutputStream *> table_output (metaData.getNoOfTables ());
1506
1507
restoreLogger.log_debug (" Restoring tables" );
1507
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1508
- restoreLogger.log_info (" %s [restore_metadata] Restoring tables" , timestamp);
1508
+ restoreLogger.log_info (" [restore_metadata] Restoring tables" );
1509
1509
1510
1510
for (i = 0 ; i<metaData.getNoOfTables (); i++)
1511
1511
{
@@ -1573,8 +1573,7 @@ main(int argc, char** argv)
1573
1573
}
1574
1574
1575
1575
restoreLogger.log_debug (" Save foreign key info" );
1576
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1577
- restoreLogger.log_info (" %s [restore_metadata] Save foreign key info" , timestamp);
1576
+ restoreLogger.log_info (" [restore_metadata] Save foreign key info" );
1578
1577
for (i = 0 ; i<metaData.getNoOfObjects (); i++)
1579
1578
{
1580
1579
for (Uint32 j= 0 ; j < g_consumers.size (); j++)
@@ -1608,8 +1607,7 @@ main(int argc, char** argv)
1608
1607
g_consumers[i]->report_meta_data (ga_backupId, ga_nodeId);
1609
1608
}
1610
1609
restoreLogger.log_debug (" Iterate over data" );
1611
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1612
- restoreLogger.log_info (" %s [restore_data] Start restoring table data" , timestamp);
1610
+ restoreLogger.log_info (" [restore_data] Start restoring table data" );
1613
1611
if (ga_restore || ga_print)
1614
1612
{
1615
1613
if (_restore_data || _print_data)
@@ -1675,9 +1673,8 @@ main(int argc, char** argv)
1675
1673
restoreLogger.log_error (" Unable to allocate memory for RestoreDataIterator constructor" );
1676
1674
exitHandler (NdbRestoreStatus::Failed);
1677
1675
}
1678
-
1679
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1680
- restoreLogger.log_info (" %s [restore_data] Read data file header" , timestamp);
1676
+
1677
+ restoreLogger.log_info (" [restore_data] Read data file header" );
1681
1678
1682
1679
// Read data file header
1683
1680
if (!dataIter.readHeader ())
@@ -1686,9 +1683,8 @@ main(int argc, char** argv)
1686
1683
" Failed to read header of data file. Exiting..." );
1687
1684
exitHandler (NdbRestoreStatus::Failed);
1688
1685
}
1689
-
1690
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1691
- restoreLogger.log_info (" %s [restore_data] Restore fragments" , timestamp);
1686
+
1687
+ restoreLogger.log_info (" [restore_data] Restore fragments" );
1692
1688
1693
1689
Uint32 fragmentId;
1694
1690
while (dataIter.readFragmentHeader (res= 0 , &fragmentId))
@@ -1759,8 +1755,7 @@ main(int argc, char** argv)
1759
1755
{
1760
1756
RestoreLogIterator logIter (metaData);
1761
1757
1762
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1763
- restoreLogger.log_info (" %s [restore_log] Read log file header" , timestamp);
1758
+ restoreLogger.log_info (" [restore_log] Read log file header" );
1764
1759
1765
1760
if (!logIter.readHeader ())
1766
1761
{
@@ -1771,8 +1766,7 @@ main(int argc, char** argv)
1771
1766
1772
1767
const LogEntry * logEntry = 0 ;
1773
1768
1774
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1775
- restoreLogger.log_info (" %s [restore_log] Restore log entries" , timestamp);
1769
+ restoreLogger.log_info (" [restore_log] Restore log entries" );
1776
1770
1777
1771
while ((logEntry = logIter.getNextLogEntry (res= 0 )) != 0 )
1778
1772
{
@@ -1848,8 +1842,7 @@ main(int argc, char** argv)
1848
1842
}
1849
1843
if (ga_restore_epoch)
1850
1844
{
1851
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1852
- restoreLogger.log_info (" %s [restore_epoch] Restoring epoch" , timestamp);
1845
+ restoreLogger.log_info (" [restore_epoch] Restoring epoch" );
1853
1846
RestoreLogIterator logIter (metaData);
1854
1847
1855
1848
if (!logIter.readHeader ())
@@ -1882,8 +1875,7 @@ main(int argc, char** argv)
1882
1875
if (ga_rebuild_indexes)
1883
1876
{
1884
1877
restoreLogger.log_debug (" Rebuilding indexes" );
1885
- Logger::format_timestamp (time (NULL ), timestamp, sizeof (timestamp));
1886
- restoreLogger.log_info (" %s [rebuild_indexes] Rebuilding indexes" , timestamp);
1878
+ restoreLogger.log_info (" [rebuild_indexes] Rebuilding indexes" );
1887
1879
1888
1880
for (i = 0 ; i<metaData.getNoOfTables (); i++)
1889
1881
{
0 commit comments