Project

General

Profile

log_fixes_2.diff

Hynek Cihlar, 02/26/2023 09:31 AM

Download (5.09 KB)

View differences:

new/build.gradle 2023-02-26 13:41:19 +0000
570 570
    fwdClient group: 'gettext', name: 'gettext.js', version: '1.2.0', ext: 'zip' // WARNING: this zip name is hardcoded in WebResourceHandler
571 571
    fwdClient group: 'org.apache.tika', name: 'tika-core', version: '1.18'
572 572
    
573
    gwtRuntime group: 'com.google.gwt', name: 'gwt-user', version: '2.9.0'
574
    gwtRuntime group: 'com.googlecode.gwt-validation', name: 'gwt-validation', version: '2.1'
573
    gwtRuntime group: 'com.google.gwt', name: 'gwt-user', version: '2.10.0'
574
    gwtRuntime (group: 'com.googlecode.gwt-validation', name: 'gwt-validation', version: '2.1') {
575
        exclude group: 'org.slf4j', module: 'slf4j-simple'
576
    }
575 577
    
576 578
    gwtRuntime group: 'org.freemarker', name: 'freemarker', version: '2.3.31'
577 579
    gwtRuntime (group: 'com.gwtplatform', name: 'gwtp-mvp-client', version: '1.6') {
new/src/com/goldencode/p2j/main/ClientDriver.java 2023-02-26 14:00:51 +0000
417 417
   {
418 418
      // for web and batch clients only redirect stderr to a log file
419 419
      setClientLog(args);
420

  
421
      // init default log format after redirecting stderr above!
422
      // do this as early as possible to ensure the same log format is used for log outputs before and
423
      // after logging is configured
424
      com.goldencode.p2j.util.LogHelper.initDefaultLoggingOptions();
420 425
      
421 426
      ClientDriver client = new ClientDriver();
422 427
      
new/src/com/goldencode/p2j/main/ServerDriver.java 2023-02-26 14:00:51 +0000
114 114
package com.goldencode.p2j.main;
115 115

  
116 116
import java.net.*;
117
import java.security.*;
118
import javax.net.ssl.*;
119
import org.bouncycastle.jsse.provider.*;
117

  
120 118
import com.goldencode.p2j.aspects.ltw.*;
121 119
import com.goldencode.p2j.cfg.*;
122 120
import com.goldencode.p2j.directory.*;
......
124 122
import com.goldencode.p2j.net.*;
125 123
import com.goldencode.p2j.security.*;
126 124
import com.goldencode.p2j.security.SecurityManager;
127
import com.goldencode.p2j.security.SecurityManager.*;
128 125
import com.goldencode.p2j.util.*;
129 126

  
130 127
/**
......
953 950
    */
954 951
   public static void main(String[] args)
955 952
   {
953
      // do this as early as possible to ensure the same log format is used for log outputs before and
954
      // after logging is configured
955
      LogHelper.initDefaultLoggingOptions();
956

  
956 957
      ServerDriver server = new ServerDriver();
957 958
      FwdJMX.init();
958 959
      server.process(args);
new/src/com/goldencode/p2j/util/LogHelper.java 2023-02-26 14:26:51 +0000
306 306
         return initWorker(fhClass);
307 307
      }
308 308
   }
309

  
310
   /**
311
    * Configures default logging options. This method performs all the necessary logging changes early at
312
    * the process startup. The security context is not accessed from this method.
313
    */
314
   public static void initDefaultLoggingOptions()
315
   {
316
      // ensure the correct log format is used even before logging is configued from the directory
317
      CleanFormatter f = new CleanFormatter();
318
      Logger rootLogger = Logger.getLogger("");
319
      Handler[] handlers = rootLogger.getHandlers();
320
      for (Handler handler : handlers) {
321
         handler.setFormatter(f);
322
      }
323

  
324
      // force Jetty to send log output to java.util.logging
325
      System.setProperty("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.JavaUtilLog");
326
   }
309 327
      
310 328
   /**
311 329
    * Retrieve a logging object from the <code>LogManager</code>.
......
1038 1056
         
1039 1057
         Date dat = new Date(record.getMillis());
1040 1058
         
1059
         // shorten the qualified name to only include first letters for the package names
1060
         StringBuilder sb = null;
1061
         String sourceName = record.getSourceClassName();
1062
         if (sourceName != null)
1063
         {
1064
            sb = new StringBuilder();
1065
            String[] names = sourceName.split("\\.");
1066
            for (int i = 0; i < names.length - 2; i++)
1067
            {
1068
               String name = names[i];
1069
               if (name.length() > 0)
1070
               {
1071
                  sb.append(name.charAt(0));
1072
               }
1073
               sb.append(".");
1074
            }
1075
            sb.append(names[names.length - 1]);
1076
         }
1077

  
1041 1078
         Object[] parms = new Object[]
1042 1079
         {
1043 1080
            sdf.get().format(dat),
1044
            record.getSourceClassName(),
1081
            sb != null ? sb.toString() : "",
1045 1082
            record.getLevel().toString(),
1046 1083
            record.getMessage(),
1047 1084
            SEP
......
1053 1090
         
1054 1091
         if (t != null)
1055 1092
         {
1056
            StringBuilder sb = new StringBuilder(out);
1093
            sb = new StringBuilder(out);
1057 1094
            dumpThrowable(t, sb);
1058 1095
            out = sb.toString();
1059 1096
         }