Skip to content

Commit 132a639

Browse files
committed
Print debug messages in standar classes when GeneXus log is enabled instead of when JDBC log is enabled.
Issue: 96165
1 parent 2c56fa8 commit 132a639

File tree

14 files changed

+92
-163
lines changed

14 files changed

+92
-163
lines changed

common/src/main/java/com/genexus/GXJarClassLoader.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

22
package com.genexus;
3+
import com.genexus.diagnostics.core.ILogger;
4+
import com.genexus.diagnostics.core.LogManager;
5+
36
import java.io.*;
47
import java.util.*;
58
import java.util.zip.*;
69

710
public class GXJarClassLoader extends ClassLoader
811
{
9-
private static final boolean DEBUG = DebugFlag.DEBUG;
1012
private String source;
1113
private ZipFile zipFile = null;
1214
private boolean sourceIsJAR;
@@ -15,6 +17,8 @@ public class GXJarClassLoader extends ClassLoader
1517
private long jarTimeStamp = 0;
1618
private boolean autoReload;
1719
private int loadDepth; // Esta variable mantiene un depth de intentos de lectura del Zip
20+
21+
private static final ILogger logger = LogManager.getLogger(GXJarClassLoader.class);
1822

1923
/** El Nombre esta medio mal, porque el GXJarClassLoader obtiene las clases de un JAR o
2024
* de una directorio base
@@ -30,8 +34,7 @@ public GXJarClassLoader(String location, boolean autoReload)
3034
sourceIsJAR = new File(source).isFile();
3135
loadDepth = 0;
3236
if(!autoReload)openJar();
33-
if(DEBUG)
34-
System.out.println("## GXJarClassLoader: Initialized (autoReloading: " + autoReload + ")");
37+
logger.debug("## GXJarClassLoader: Initialized (autoReloading: " + autoReload + ")");
3538
}
3639

3740
/** Obtiene el ClassLoader asociado. En efecto lo que hace es retornarse a s� mismo en el
@@ -45,8 +48,7 @@ public GXJarClassLoader getClassLoaderInstance()
4548
return this;
4649
else
4750
{
48-
if (DEBUG)
49-
System.out.println("## GXJarClassLoader: Changed classes detected ..." );
51+
logger.debug("## GXJarClassLoader: Changed classes detected ..." );
5052
return new GXJarClassLoader(source, autoReload);
5153
}
5254
}
@@ -134,8 +136,7 @@ public synchronized Class loadClass(String className, boolean resolveIt) throws
134136
try
135137
{
136138
result = this.getClass().getClassLoader().loadClass(className);
137-
if(DEBUG)
138-
System.out.println("## GXJarClassLoader: Loading ParentClass: " + className);
139+
logger.debug("## GXJarClassLoader: Loading ParentClass: " + className);
139140
return result;
140141
}catch(Throwable e) { ; }
141142
throw new ClassNotFoundException(className);
@@ -168,8 +169,7 @@ private byte[] loadBytes(String className)
168169
byte[] result = null;
169170
className = className.replace('.', '/') + ".class";
170171

171-
if(DEBUG)
172-
System.out.println("## GXJarClassLoader: Loading class: " + className + " [" + source + "]");
172+
logger.debug("## GXJarClassLoader: Loading class: " + className + " [" + source + "]");
173173
try
174174
{
175175
if(sourceIsJAR)

common/src/main/java/com/genexus/ModelContext.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.genexus.common.interfaces.IClientPreferences;
1010
import com.genexus.common.interfaces.IPreferences;
1111
import com.genexus.common.interfaces.SpecificImplementation;
12+
import com.genexus.diagnostics.core.ILogger;
13+
import com.genexus.diagnostics.core.LogManager;
1214
import com.genexus.util.GUIContextNull;
1315
import com.genexus.util.GXThreadLocal;
1416
import com.genexus.util.IGUIContext;
@@ -34,17 +36,15 @@ public final class ModelContext extends AbstractModelContext
3436
public boolean inErrorHandler = false;
3537

3638
public static IThreadLocal threadModelContext = GXThreadLocal.newThreadLocal();
39+
private static final ILogger logger = LogManager.getLogger(ModelContext.class);
3740

3841
public static ModelContext getModelContext()
3942
{
4043
ModelContext context = (ModelContext)threadModelContext.get();
41-
if(DebugFlag.DEBUG)
42-
{
43-
if(context == null)
44-
{
45-
System.err.println(new Date() + " - Cannot find ModelContext for thread " + Thread.currentThread() );
46-
}
47-
}
44+
if(context == null)
45+
{
46+
logger.error(new Date() + " - Cannot find ModelContext for thread " + Thread.currentThread() );
47+
}
4848
return context;
4949
}
5050

common/src/main/java/com/genexus/diagnostics/core/ILogger.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public interface ILogger {
5656

5757
boolean isDebugEnabled();
5858

59+
boolean isErrorEnabled();
60+
5961
// Lambda Functions not supported JAVA 7. Only Java 8.
6062
/*
6163
* public static void debug(Logger log, String startMsg, Func<String> buildMsg)

common/src/main/java/com/genexus/internet/GXInternetConstants.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
public interface GXInternetConstants
55
{
6-
static boolean DEBUG = com.genexus.DebugFlag.DEBUG;
7-
86
static String CRLFString = System.getProperty("line.separator");
97

108
static String BASE64 = "base64";

common/src/main/java/com/genexus/internet/RFC822EndReader.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
11
package com.genexus.internet;
22

3+
import com.genexus.diagnostics.core.ILogger;
4+
import com.genexus.diagnostics.core.LogManager;
5+
36
import java.io.*;
47

5-
class RFC822EndReader extends BufferedReader implements GXInternetConstants
8+
public class RFC822EndReader extends BufferedReader implements GXInternetConstants
69
{
710
private String lastLine;
811
private boolean isEndOfMessage = false;
9-
private PrintStream logOutput;
12+
private static final ILogger logger = LogManager.getLogger(RFC822EndReader.class);
1013

11-
public RFC822EndReader(Reader reader, PrintStream logOutput)
14+
public RFC822EndReader(Reader reader)
1215
{
1316
super(reader);
14-
this.logOutput = logOutput;
1517
}
1618

1719
private int log(int line)
1820
{
19-
if (DEBUG)
20-
{
21-
if (logOutput != null)
22-
logOutput.println("byte: " + line);
23-
}
24-
21+
logger.debug("byte: " + line);
2522
return line;
2623
}
2724

2825
private String log(String line)
2926
{
30-
if (DEBUG)
31-
{
32-
if (logOutput != null)
33-
logOutput.println("Line: " + line);
34-
}
27+
logger.debug("Line: " + line);
3528

3629
return line;
3730
}

common/src/main/java/com/genexus/util/DelimitedFilesSafe.java

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.io.*;
88

99
import com.genexus.*;
10+
import com.genexus.diagnostics.core.ILogger;
11+
import com.genexus.diagnostics.core.LogManager;
1012
import com.genexus.platform.INativeFunctions;
1113
import com.genexus.common.interfaces.SpecificImplementation;
1214

@@ -15,6 +17,7 @@
1517
public class DelimitedFilesSafe implements IDelimitedFilesSafe
1618
{
1719
// variables
20+
private static final ILogger logger = LogManager.getLogger(DelimitedFilesSafe.class);
1821

1922
private static final byte GX_ASCDEL_SUCCESS = 0;
2023
private static final byte GX_ASCDEL_INVALIDSEQUENCE = -1;
@@ -36,7 +39,6 @@ public class DelimitedFilesSafe implements IDelimitedFilesSafe
3639
private String sdel;
3740
protected boolean dfropen_in_use = false;
3841
protected boolean dfwopen_in_use = false;
39-
protected boolean trace_on = DebugFlag.DEBUG;
4042
protected BufferedReader bufread;
4143
protected BufferedWriter bufwrite;
4244
private StringTokenizer actline;
@@ -59,8 +61,7 @@ public String getEncoding()
5961

6062
public byte dftrace(int trace)
6163
{
62-
byte lastTrace = (byte)(trace_on ? 1 : 0);
63-
this.trace_on = (trace != 0);
64+
byte lastTrace = 1;
6465
return lastTrace;
6566
}
6667

@@ -143,16 +144,14 @@ public Object run() throws Exception
143144
{
144145
retval = GX_ASCDEL_OPENERROR;
145146
dfropen_in_use = false;
146-
if (trace_on)
147-
System.err.println("Error ADF0001: " + e);
147+
logger.error("Error ADF0001: " + e);
148148
}
149149

150150
}
151151
else
152152
{
153153
retval = GX_ASCDEL_INVALIDSEQUENCE;
154-
if (trace_on)
155-
System.err.println("Error ADF0005: open function in use");
154+
logger.error("Error ADF0005: open function in use");
156155
}
157156

158157
return retval;
@@ -181,8 +180,7 @@ public byte dfrnext()
181180
catch (IOException e)
182181
{
183182
retval = GX_ASCDEL_READERROR;
184-
if (trace_on)
185-
System.err.println("Error ADF0002: " + e);
183+
logger.error("Error ADF0002: " + e);
186184
}
187185

188186
}else{
@@ -214,15 +212,13 @@ public byte dfrgnum(double[] num)
214212
catch (Exception e)
215213
{
216214
retval = GX_ASCDEL_INVALIDFORMAT;
217-
if (trace_on)
218-
System.err.println("Error ADF0008: " + e);
215+
logger.error("Error ADF0008: " + e);
219216
}
220217
}
221218
else
222219
{
223220
retval = GX_ASCDEL_INVALIDSEQUENCE;
224-
if (trace_on)
225-
System.err.println("Error ADF0004 o ADF0006");
221+
logger.error("Error ADF0004 o ADF0006");
226222
}
227223

228224
num[0] = retnum.doubleValue();
@@ -258,15 +254,13 @@ public byte dfrgnum(BigDecimal[] num)
258254
catch (Exception e)
259255
{
260256
retval = GX_ASCDEL_INVALIDFORMAT;
261-
if (trace_on)
262-
System.err.println("Error ADF0008: " + e);
257+
logger.error("Error ADF0008: " + e);
263258
}
264259
}
265260
else
266261
{
267262
retval = GX_ASCDEL_INVALIDSEQUENCE;
268-
if (trace_on)
269-
System.err.println("Error ADF0004 o ADF0006");
263+
logger.error("Error ADF0004 o ADF0006");
270264
}
271265

272266
num[0] = retnum;
@@ -360,15 +354,13 @@ public byte dfrgtxt(String[] str, int len)
360354
catch (Exception e)
361355
{
362356
retval = GX_ASCDEL_INVALIDFORMAT;
363-
if (trace_on)
364-
System.err.println("Error ADF0009: " + e);
357+
logger.error("Error ADF0009: " + e);
365358
}
366359
}
367360
else
368361
{
369362
retval = GX_ASCDEL_INVALIDSEQUENCE;
370-
if (trace_on)
371-
System.err.println("Error ADF0004 o ADF0006");
363+
logger.error("Error ADF0004 o ADF0006");
372364
}
373365

374366
if (isCsv && ((sdel.equals("") || sdel.equals("\"")) && (retstr.contains("\"\"") || (!fdel.equals("") && retstr.contains(fdel)))))
@@ -534,8 +526,7 @@ public byte dfrgdate(java.util.Date[] date, String fmt, String sep)
534526
else if (month < 1 || month > 12 || day < 1 || day > 31)
535527
{
536528
retval = GX_ASCDEL_INVALIDDATE;
537-
if (trace_on)
538-
System.err.println("Error ADF0010");
529+
logger.error("Error ADF0010");
539530
}
540531
else
541532
{
@@ -553,8 +544,7 @@ else if (month < 1 || month > 12 || day < 1 || day > 31)
553544
else
554545
{
555546
retval = GX_ASCDEL_INVALIDSEQUENCE;
556-
if (trace_on)
557-
System.err.println("Error ADF0004 o ADF0006");
547+
logger.error("Error ADF0004 o ADF0006");
558548
}
559549

560550
date[0] = retdate;
@@ -666,16 +656,14 @@ public Object run() throws Exception
666656
{
667657
retval = GX_ASCDEL_OPENERROR;
668658
dfwopen_in_use = false;
669-
if (trace_on)
670-
System.err.println("Error ADF0001: " + e);
659+
logger.error("Error ADF0001: " + e);
671660
}
672661

673662
}
674663
else
675664
{
676665
retval = GX_ASCDEL_INVALIDSEQUENCE;
677-
if (trace_on)
678-
System.err.println("Error ADF0005: open function in use");
666+
logger.error("Error ADF0005: open function in use");
679667
}
680668

681669
return retval;
@@ -737,8 +725,7 @@ public byte dfwnext()
737725
catch (IOException e)
738726
{
739727
retval = GX_ASCDEL_WRITEERROR;
740-
if (trace_on)
741-
System.err.println("Error ADF0003: " + e);
728+
logger.error("Error ADF0003: " + e);
742729
}
743730
}
744731
else
@@ -795,8 +782,7 @@ public byte dfwpnum(double num, int dec)
795782
else
796783
{
797784
retval = GX_ASCDEL_INVALIDSEQUENCE;
798-
if (trace_on)
799-
System.err.println("ADF0004");
785+
logger.error("ADF0004");
800786
}
801787
return retval;
802788
}
@@ -829,8 +815,7 @@ public byte dfwptxt(String txt, int len)
829815
else
830816
{
831817
retval = GX_ASCDEL_INVALIDSEQUENCE;
832-
if (trace_on)
833-
System.err.println("ADF0004");
818+
logger.error("ADF0004");
834819
}
835820
return retval;
836821
}
@@ -888,8 +873,7 @@ public byte dfwpdate(Date date, String fmt, String sep)
888873
toWrite += day + (i == 2?"":sep);
889874
break;
890875
default:
891-
if (trace_on)
892-
System.err.println("ADF0012");
876+
logger.error("ADF0012");
893877

894878
return GX_ASCDEL_BADFMTSTR;
895879
}
@@ -898,8 +882,7 @@ public byte dfwpdate(Date date, String fmt, String sep)
898882
else
899883
{
900884
retval = GX_ASCDEL_INVALIDSEQUENCE;
901-
if (trace_on)
902-
System.err.println("ADF0004");
885+
logger.error("ADF0004");
903886
}
904887
return retval;
905888
}

0 commit comments

Comments
 (0)