← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18985: Clock, added option for passing in specific log

 

------------------------------------------------------------
revno: 18985
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-04-22 17:42:48 +0200
message:
  Clock, added option for passing in specific log
modified:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Clock.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java	2015-04-16 21:17:08 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java	2015-04-22 15:42:48 +0000
@@ -106,8 +106,6 @@
     // Supportive methods
     // -------------------------------------------------------------------------
 
-    //TODO use DefaultAnalyticsTableService generateAll ?
-    
     private void generateAll()
     {
         resourceTableService.dropAllSqlViews();

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2015-04-17 08:57:30 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2015-04-22 15:42:48 +0000
@@ -97,7 +97,7 @@
         int processNo = getProcessNo();
         int orgUnitLevelNo = organisationUnitService.getMaxOfOrganisationUnitLevels();
         
-        Clock clock = new Clock().startClock().logTime( "Starting update, processes: " + processNo + ", org unit levels: " + orgUnitLevelNo );
+        Clock clock = new Clock( log ).startClock().logTime( "Starting update, processes: " + processNo + ", org unit levels: " + orgUnitLevelNo );
         
         String validState = tableManager.validState();
         
@@ -112,7 +112,7 @@
         final List<AnalyticsTable> tables = tableManager.getTables( earliest );
         final String tableName = tableManager.getTableName();
         
-        clock.logTime( "Table update start: " + tableName + ", partitions: " + tables + ", last years: " + lastYears + ", earliest: " + earliest );
+        clock.logTime( "Table update start: " + tableName + ", processes: " + processNo + ", partitions: " + tables + ", last years: " + lastYears + ", earliest: " + earliest );
         notifier.notify( taskId, "Performing pre-create table work, processes: " + processNo + ", org unit levels: " + orgUnitLevelNo );
         
         tableManager.preCreateTables();

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Clock.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Clock.java	2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Clock.java	2015-04-22 15:42:48 +0000
@@ -39,14 +39,22 @@
 public class Clock
     extends StopWatch
 {
-    private static final Log log = LogFactory.getLog( Clock.class );
-    
     private static final String SEPARATOR = ": ";
     
+    private static final Log defaultLog = LogFactory.getLog( Clock.class );
+    
+    private Log log;
+    
     public Clock()
     {
         super();
     }
+
+    public Clock( Log log )
+    {
+        super();
+        this.log = log;
+    }
     
     public Clock startClock()
     {
@@ -68,7 +76,16 @@
         
         String time = DurationFormatUtils.formatDurationHMS( super.getSplitTime() ); 
         
-        log.info( message + SEPARATOR + time );
+        String msg = message + SEPARATOR + time;
+        
+        if ( log != null )
+        {
+            log.info( msg );
+        }
+        else
+        {
+            defaultLog.info( msg );
+        }
         
         return this;
     }