Project

General

Profile

logging.patch

Galya B, 04/22/2024 06:34 AM

Download (18.7 KB)

View differences:

build.gradle 2024-04-22 10:32:34 +0000
145 145
**     TJD 20240213 Gradle update to 7.6.4, update of Jetty to latest 9 version, dependency check plugin 
146 146
**     TJD 20240219 dependencyCheck plugin configuration
147 147
**     TJD 20240415 upgrade JS dependencies
148
**     GBB 20240422 Remove logging libs except slf4j.
148 149
*/
149 150

  
150 151
/*
......
440 441
    }
441 442
    // remove apis already provided by java 11+
442 443
    if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
444
       exclude group: 'commons-logging', module: "commons-logging"
443 445
       exclude group: 'xml-apis', module: "xml-apis"
444 446
       exclude group: 'org.slf4j', module: 'slf4j-simple'
445 447
       exclude group: 'org.apache.xmlgraphics', module: 'batik-ext'
......
472 474
       fwdCCS group: 'jakarta.xml.ws', name: 'jakarta.xml.ws-api', version: '2.3.3'
473 475
    }
474 476
    fwdCCS group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
475
    fwdConvertServer group: 'org.jboss.logging', name: 'jboss-logging', version: '3.5.3.Final'
476 477
    fwdConvertServer group: 'antlr', name: 'antlr', version: '2.7.7'
477 478
    fwdConvertServer group: 'com.goldencode', name: 'fwd-h2', version: '1.45-trunk'
478 479
    fwdConvertServer group: 'javax.transaction', name: 'jta', version: '1.1'
......
487 488
    fwdConvert group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.16.1'
488 489
    fwdConvert group: 'org.aspectj', name: 'aspectjtools', version: aspectjVersion
489 490
   
490
    // commons-logging
491
    fwdClientServer group: 'commons-logging', name: 'commons-logging', version: '1.3.0'
492 491
    // upgraded slf4j
493 492
    fwdClientServer group: 'org.slf4j', name: 'slf4j-api', version: '2.0.12'
494
    fwdClientServer group: 'org.slf4j', name: 'slf4j-jdk14', version: '2.0.12'
493
    fwdClientServer group: 'org.slf4j', name: 'jcl-over-slf4j', version: '2.0.12'
495 494

  
496 495
    // latest Jetty 9 series
497 496
    fwdClientServer group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.4.53.v20231009'
......
562 561
    fwdServer (group: 'net.sourceforge.barbecue', name: 'barbecue', version: '1.5-beta1') {
563 562
        exclude group: 'bouncycastle'
564 563
    }
565
    fwdServer group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.22.1'
566
    fwdServer group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.22.1'
567 564
    
568 565
    fwdServer (group: 'org.ghost4j', name: 'ghost4j', version: '1.0.1') {
569 566
        exclude group: 'bouncycastle'
build.xml 2024-04-22 10:16:22 +0000
263 263
** 113 RFB 20240102          Update the spawner archive to include all the necessary spawner jars. Ref. #7589.
264 264
** 114 RFB 20240227          Update the spawner archive to include an additional jar (aspectjrt). Ref. #8230.
265 265
** 115 TJD 20240216          Java 17 updates, javac and iac tasks need 2GB of RAM for Java8
266
**     GBB 20240422          Slf4j impl separate jar removed.
266 267
-->
267 268

  
268 269
<!--
......
495 496

  
496 497
    <path refid="compile.classpath"/>
497 498
    <pathelement location="${build.home}/lib/p2j.jar"/>
498
    <pathelement location="${build.home}/lib/fwd-slf4j.jar"/>
499 499

  
500 500
  </path>
501 501

  
......
1107 1107
        <zipfileset dir="${basedir}/build/lib" 
1108 1108
                    prefix="lib"
1109 1109
                    includes="p2j.jar 
1110
                              fwd-slf4j.jar 
1111 1110
                              fwdaopltw.jar
1112 1111
                              fwd_sheet.war
1113 1112
                              ${libname}" />
......
1126 1125
        <zipfileset dir="${basedir}/build/lib" 
1127 1126
                    prefix="lib"
1128 1127
                    includes="p2j.jar
1129
                              fwd-slf4j.jar 
1130 1128
                              ${libname}" />
1131 1129
        <zipfileset dir="${dist.home}/client" 
1132 1130
                    prefix="lib"
......
1154 1152
                    filemode="755" />
1155 1153
        <zipfileset dir="${basedir}/build/lib"
1156 1154
                    includes="p2j.jar
1157
                              aspectjrt*.jar
1158
                              fwd-slf4j.jar" />
1155
                              aspectjrt*.jar />
1159 1156
    </zip>
1160 1157
    <chmod file="${archive.spawner_destfile}" perm="755"/>
1161 1158

  
......
1730 1727
          manifest="${manifest.dir}/p2j.mf"
1731 1728
     />
1732 1729
     
1733
     <jar jarfile="${build.home}/lib/fwd-slf4j.jar"
1734
          basedir="${build.home}/classes.aop"
1735
          includes="org/slf4j/**"
1736
          manifest="${manifest.dir}/fwdslf4j.mf"
1737
     />
1738
     
1739 1730
     <jar update="true" jarfile="${build.home}/lib/p2j.jar"
1740 1731
          basedir="${build.home}"
1741 1732
          includes="udf/**/udfs.sql udf/**/words-udfs-*.sql"
src/com/goldencode/p2j/util/logging/CentralSlf4jLogger.java 2024-04-22 10:17:09 +0000
2 2
 ** Module   : CentralSlf4jLogger.java
3 3
 ** Abstract : Implementation of slf4j logger that proxies to CentralLogger.
4 4
 **
5
 ** Copyright (c) 2023, Golden Code Development Corporation.
5
 ** Copyright (c) 2023-2024, Golden Code Development Corporation.
6 6
 **
7 7
 ** -#- -I- --Date-- ----------------------------Description-----------------------------
8 8
 ** 001 GBB 20230327 Initial setup
9
 ** 002 GBB 20240422 Implementation of api 2.0 
9 10
 */
10 11
/*
11 12
 ** This program is free software: you can redistribute it and/or modify
......
61 62
 */
62 63
package com.goldencode.p2j.util.logging;
63 64

  
64
import com.goldencode.p2j.util.logging.*;
65 65
import org.slf4j.*;
66
import org.slf4j.Logger;
67 66
import org.slf4j.helpers.*;
67
import org.slf4j.spi.*;
68 68

  
69
import java.util.*;
69 70
import java.util.logging.*;
70 71

  
71 72
/**
......
91 92
 * </table>
92 93
 */
93 94
public class CentralSlf4jLogger
94
implements Logger
95
extends LegacyAbstractLogger
96
implements LocationAwareLogger
95 97
{
98
   /** Map of slf4j levels to java logging levels. */
99
   private static final Map<org.slf4j.event.Level, java.util.logging.Level> slf4jToJavaLevelMap =
100
      new HashMap<org.slf4j.event.Level, java.util.logging.Level>() {{
101
         put(org.slf4j.event.Level.ERROR, Level.SEVERE);
102
         put(org.slf4j.event.Level.WARN, Level.WARNING);
103
         put(org.slf4j.event.Level.INFO, Level.INFO);
104
         put(org.slf4j.event.Level.DEBUG, Level.FINE);
105
         put(org.slf4j.event.Level.TRACE, Level.FINER);
106
      }};
107
   
96 108
   /** The instance of CentralLogger to forward logs to. */
97 109
   private final CentralLogger logger;
98 110

  
......
979 991
   }
980 992

  
981 993
   /**
994
    * Printing method with support for location information.
995
    *
996
    * @param    marker
997
    *           The marker to be used for this event, may be null.
998
    * @param    fqcn
999
    *           The fully qualified class name of the logger instance, typically the logger class.
1000
    * @param    slf4jLevelInt
1001
    *           One of the level integers defined in this interface.
1002
    * @param    format
1003
    *           The message for the log event.
1004
    * @param    args
1005
    *           The arguments for the message format.
1006
    * @param    t
1007
    *           Throwable associated with the log event, may be null.
1008
    */
1009
   @Override
1010
   public void log(Marker marker, String fqcn, int slf4jLevelInt, String format, Object[] args, Throwable t)
1011
   {
1012
      handleNormalizedLoggingCall(org.slf4j.event.Level.intToLevel(slf4jLevelInt), marker, format, args, t);
1013
   }
1014

  
1015
   /**
1016
    * Unknown. No slf4j doc, but from examples it seems to be the slf4j implementation class name.
1017
    * 
1018
    * @return See above.
1019
    */
1020
   @Override
1021
   protected String getFullyQualifiedCallerName()
1022
   {
1023
      return CentralSlf4jLogger.class.getName();
1024
   }
1025

  
1026
   /**
1027
    * Given various arguments passed as parameters, perform actual logging. This method assumes that the 
1028
    * separation of the args array into actual objects and a throwable has been already operated.
1029
    * 
1030
    * @param    slf4jLevel
1031
    *           the SLF4J level for this event
1032
    * @param    marker 
1033
    *           The marker to be used for this event, may be null.
1034
    * @param    format
1035
    *           The message pattern which will be parsed and formatted
1036
    * @param    args
1037
    *           The array of arguments to be formatted, may be null
1038
    * @param    t
1039
    *           The exception whose stack trace should be logged, may be null
1040
    */
1041
   @Override
1042
   protected void handleNormalizedLoggingCall(org.slf4j.event.Level slf4jLevel,
1043
                                              Marker marker,
1044
                                              String format,
1045
                                              Object[] args,
1046
                                              Throwable t)
1047
   {
1048
      Level logLevel = slf4jToJavaLevelMap.get(slf4jLevel);
1049
      if (logLevel == null)
1050
      {
1051
         throw new IllegalStateException("Unexpected value: " + slf4jLevel);
1052
      }
1053
      logger.log(logLevel, format(format, args), t);
1054
   }
1055

  
1056
   /**
982 1057
    * Returns the message formatted according to org.eclipse.jetty.util.log.JettyAwareLogger - an slf4j 
983 1058
    * formatting method compatible with Jetty's logs.
984 1059
    *
src/com/goldencode/p2j/util/logging/CentralSlf4jProvider.java 2024-04-22 09:14:18 +0000
1
/*
2
 ** Module   : CentralSlf4jProvider.java
3
 ** Abstract : Implementation of slf4j provider.
4
 **
5
 ** Copyright (c) 2024, Golden Code Development Corporation.
6
 **
7
 ** -#- -I- --Date-- ----------------------------Description-----------------------------
8
 ** 001 GBB 20240422 Initial setup
9
 */
10
/*
11
 ** This program is free software: you can redistribute it and/or modify
12
 ** it under the terms of the GNU Affero General Public License as
13
 ** published by the Free Software Foundation, either version 3 of the
14
 ** License, or (at your option) any later version.
15
 **
16
 ** This program is distributed in the hope that it will be useful,
17
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 ** GNU Affero General Public License for more details.
20
 **
21
 ** You may find a copy of the GNU Affero GPL version 3 at the following
22
 ** location: https://www.gnu.org/licenses/agpl-3.0.en.html
23
 **
24
 ** Additional terms under GNU Affero GPL version 3 section 7:
25
 **
26
 **   Under Section 7 of the GNU Affero GPL version 3, the following additional
27
 **   terms apply to the works covered under the License.  These additional terms
28
 **   are non-permissive additional terms allowed under Section 7 of the GNU
29
 **   Affero GPL version 3 and may not be removed by you.
30
 **
31
 **   0. Attribution Requirement.
32
 **
33
 **     You must preserve all legal notices or author attributions in the covered
34
 **     work or Appropriate Legal Notices displayed by works containing the covered
35
 **     work.  You may not remove from the covered work any author or developer
36
 **     credit already included within the covered work.
37
 **
38
 **   1. No License To Use Trademarks.
39
 **
40
 **     This license does not grant any license or rights to use the trademarks
41
 **     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
42
 **     of Golden Code Development Corporation. You are not authorized to use the
43
 **     name Golden Code, FWD, or the names of any author or contributor, for
44
 **     publicity purposes without written authorization.
45
 **
46
 **   2. No Misrepresentation of Affiliation.
47
 **
48
 **     You may not represent yourself as Golden Code Development Corporation or FWD.
49
 **
50
 **     You may not represent yourself for publicity purposes as associated with
51
 **     Golden Code Development Corporation, FWD, or any author or contributor to
52
 **     the covered work, without written authorization.
53
 **
54
 **   3. No Misrepresentation of Source or Origin.
55
 **
56
 **     You may not represent the covered work as solely your work.  All modified
57
 **     versions of the covered work must be marked in a reasonable way to make it
58
 **     clear that the modified work is not originating from Golden Code Development
59
 **     Corporation or FWD.  All modified versions must contain the notices of
60
 **     attribution required in this license.
61
 */
62
package com.goldencode.p2j.util.logging;
63

  
64
import org.slf4j.*;
65
import org.slf4j.helpers.*;
66
import org.slf4j.spi.*;
67

  
68
/** Implementation of slf4j provider. */
69
public class CentralSlf4jProvider
70
implements SLF4JServiceProvider
71
{
72
   /** The custom logger factory. */
73
   private static final CentralSlf4jLoggerFactory loggerFactory = new CentralSlf4jLoggerFactory();
74

  
75
   /** The default base marker factory. */
76
   private static IMarkerFactory markerFactory = new BasicMarkerFactory();
77

  
78
   /** The default base mdc adapter. */
79
   private static MDCAdapter mdcAdapter = new BasicMDCAdapter();
80
   
81
   /** 
82
    * The lowest compatible api version.
83
    * <p>
84
    * To avoid constant folding by the compiler, this field must *not* be final
85
    */
86
   public static String REQUESTED_API_VERSION = "2.0.0"; // !final
87
   
88
   /**
89
    * Returns the logger factory instance.
90
    *
91
    * @return   See above.
92
    */
93
   @Override
94
   public ILoggerFactory getLoggerFactory()
95
   {
96
      return loggerFactory;
97
   }
98

  
99
   /**
100
    * Return the marker factory instance.
101
    *
102
    * @return   See above.
103
    */
104
   @Override
105
   public IMarkerFactory getMarkerFactory()
106
   {
107
      return markerFactory;
108
   }
109

  
110
   /**
111
    * Returns the mdc adapter instance.
112
    *
113
    * @return   See above.
114
    */
115
   @Override
116
   public MDCAdapter getMDCAdapter()
117
   {
118
      return mdcAdapter;
119
   }
120

  
121
   /**
122
    * Returns the lowest compatible api version.
123
    *
124
    * @return   See above.
125
    */
126
   @Override
127
   public String getRequestedApiVersion()
128
   {
129
      return REQUESTED_API_VERSION;
130
   }
131

  
132
   /**
133
    * Initialization of all factories and adapters needed.
134
    */
135
   @Override
136
   public void initialize()
137
   {
138
      // all fields are static final
139
   }
140
}
src/org/slf4j/impl/StaticLoggerBinder.java 1970-01-01 00:00:00 +0000
1
/*
2
 ** Module   : StaticLoggerBinder.java
3
 ** Abstract : Implementation of slf4j logger factory binder.
4
 **
5
 ** Copyright (c) 2023, Golden Code Development Corporation.
6
 **
7
 ** -#- -I- --Date-- ----------------------------Description-----------------------------
8
 ** 001 GBB 20230327 Initial setup
9
 ** 002 TJD 20240208 Java 17 compatibility updates
10
 */
11
/*
12
 ** This program is free software: you can redistribute it and/or modify
13
 ** it under the terms of the GNU Affero General Public License as
14
 ** published by the Free Software Foundation, either version 3 of the
15
 ** License, or (at your option) any later version.
16
 **
17
 ** This program is distributed in the hope that it will be useful,
18
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 ** GNU Affero General Public License for more details.
21
 **
22
 ** You may find a copy of the GNU Affero GPL version 3 at the following
23
 ** location: https://www.gnu.org/licenses/agpl-3.0.en.html
24
 **
25
 ** Additional terms under GNU Affero GPL version 3 section 7:
26
 **
27
 **   Under Section 7 of the GNU Affero GPL version 3, the following additional
28
 **   terms apply to the works covered under the License.  These additional terms
29
 **   are non-permissive additional terms allowed under Section 7 of the GNU
30
 **   Affero GPL version 3 and may not be removed by you.
31
 **
32
 **   0. Attribution Requirement.
33
 **
34
 **     You must preserve all legal notices or author attributions in the covered
35
 **     work or Appropriate Legal Notices displayed by works containing the covered
36
 **     work.  You may not remove from the covered work any author or developer
37
 **     credit already included within the covered work.
38
 **
39
 **   1. No License To Use Trademarks.
40
 **
41
 **     This license does not grant any license or rights to use the trademarks
42
 **     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
43
 **     of Golden Code Development Corporation. You are not authorized to use the
44
 **     name Golden Code, FWD, or the names of any author or contributor, for
45
 **     publicity purposes without written authorization.
46
 **
47
 **   2. No Misrepresentation of Affiliation.
48
 **
49
 **     You may not represent yourself as Golden Code Development Corporation or FWD.
50
 **
51
 **     You may not represent yourself for publicity purposes as associated with
52
 **     Golden Code Development Corporation, FWD, or any author or contributor to
53
 **     the covered work, without written authorization.
54
 **
55
 **   3. No Misrepresentation of Source or Origin.
56
 **
57
 **     You may not represent the covered work as solely your work.  All modified
58
 **     versions of the covered work must be marked in a reasonable way to make it
59
 **     clear that the modified work is not originating from Golden Code Development
60
 **     Corporation or FWD.  All modified versions must contain the notices of
61
 **     attribution required in this license.
62
 */
63
package org.slf4j.impl;
64

  
65
import com.goldencode.p2j.util.logging.*;
66
import org.slf4j.*;
67
import org.slf4j.spi.*;
68

  
69
/**
70
 * The class name and package name should exactly match what slf4j lib expects to find for it to be able to
71
 * load this custom implementation. This is a very standard implementation.
72
 */
73
@SuppressWarnings("deprecation")
74
public class StaticLoggerBinder
75
implements LoggerFactoryBinder
76
{
77
   /**
78
    * The version of the slf4j api this implementation works for. The name of the field should not be 
79
    * changed. 
80
    */
81
   public static String REQUESTED_API_VERSION = "1.6";
82

  
83
   /** The custom logger factory. */
84
   private static final CentralSlf4jLoggerFactory loggerFactory = new CentralSlf4jLoggerFactory();
85
   
86
   /** The unique instance of this class. */
87
   private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
88

  
89
   /**
90
    * Return the singleton of this class.
91
    *
92
    * @return   The CentralSlf4jBinder singleton
93
    */
94
   public static StaticLoggerBinder getSingleton() {
95
      return SINGLETON;
96
   }
97

  
98
   /**
99
    * Return the logger factory instance.
100
    * 
101
    * @return   The logger factory instance.
102
    */
103
   @Override
104
   public ILoggerFactory getLoggerFactory()
105
   {
106
      return loggerFactory;
107
   }
108
   
109
   /**
110
    * Return the logger factory class name.
111
    *
112
    * @return   The logger factory class name.
113
    */
114
   @Override
115
   public String getLoggerFactoryClassStr()
116
   {
117
      return CentralSlf4jLoggerFactory.class.getName();
118
   }
119
}