A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/commit/a4e4acb4d9e3e404d76be2fe8eda80db4cb3d160 below:

Simplify code · pmd/pmd@a4e4acb · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+16

-22

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+16

-22

lines changed Original file line number Diff line number Diff line change

@@ -13,7 +13,10 @@

13 13

import java.util.logging.LogRecord;

14 14 15 15

import org.apache.tools.ant.BuildListener;

16 +

import org.apache.tools.ant.DefaultLogger;

16 17

import org.apache.tools.ant.Project;

18 +

import org.apache.tools.ant.XmlLogger;

19 +

import org.apache.tools.ant.taskdefs.RecorderEntry;

17 20 18 21

/**

19 22

* AntLogHandler sends log messages to an Ant Task, so the regular Ant logging

@@ -34,42 +37,33 @@ public AntLogHandler(Project project) {

34 37

}

35 38 36 39

public Level getAntLogLevel() {

37 -

Class<?> clazz;

38 -

int maxLevel = Project.MSG_ERR;

39 40

for (final BuildListener l : project.getBuildListeners()) {

40 -

clazz = l.getClass();

41 41

Field declaredField = null;

42 42

try {

43 -

while (BuildListener.class.isAssignableFrom(clazz)) {

43 +

if (l instanceof DefaultLogger) {

44 +

declaredField = DefaultLogger.class.getDeclaredField("msgOutputLevel");

45 +

} else if (l instanceof XmlLogger) {

46 +

declaredField = XmlLogger.class.getDeclaredField("msgOutputLevel");

47 +

} else if (l instanceof RecorderEntry) {

48 +

declaredField = RecorderEntry.class.getDeclaredField("loglevel");

49 +

} else {

44 50

try {

45 -

declaredField = clazz.getDeclaredField("msgOutputLevel");

46 -

} catch (final NoSuchFieldException ignored) {

47 -

try {

48 -

declaredField = clazz.getDeclaredField("logLevel");

49 -

} catch (final NoSuchFieldException expected) {

50 -

// ignore it

51 -

}

51 +

declaredField = l.getClass().getDeclaredField("logLevel");

52 +

} catch (final NoSuchFieldException e) {

53 +

project.log("Unsupported build listener: " + l.getClass(), Project.MSG_WARN);

52 54

}

53 -

if (declaredField != null) {

54 -

break;

55 -

}

56 - 57 -

clazz = clazz.getSuperclass();

58 55

}

59 56 60 57

if (declaredField != null) {

61 58

declaredField.setAccessible(true);

62 -

final int level = declaredField.getInt(l);

63 -

if (maxLevel < level) {

64 -

maxLevel = level;

65 -

}

59 +

return LOG_LEVELS[declaredField.getInt(l)];

66 60

}

67 -

} catch (final IllegalArgumentException | IllegalAccessException ignored) {

61 +

} catch (final NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {

68 62

// Just ignore it

69 63

}

70 64

}

71 65 72 -

return LOG_LEVELS[maxLevel];

66 +

return Level.FINEST;

73 67

}

74 68 75 69

@Override

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4