Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete methods from Logger that are deprecated since 10+ years #1020

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions src/freenet/support/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,35 +216,7 @@ public enum LogLevel {
public boolean matchesThreshold(LogLevel threshold) {
return this.ordinal() >= threshold.ordinal();
}

@Deprecated
public static LogLevel fromOrdinal(int ordinal) {
for(LogLevel level : LogLevel.values()) {
if(level.ordinal() == ordinal)
return level;
}

throw new RuntimeException("Invalid ordinal: " + ordinal);
}
}

@Deprecated
public static final int ERROR = LogLevel.ERROR.ordinal();

@Deprecated
public static final int WARNING = LogLevel.WARNING.ordinal();

@Deprecated
public static final int NORMAL = LogLevel.NORMAL.ordinal();

@Deprecated
public static final int MINOR = LogLevel.MINOR.ordinal();
Copy link
Contributor

@ArneBab ArneBab Dec 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are used from plugins (I see them in Thingamablog, Spider, and SCGIPublisher). I do not think we can get rid of them earlier than the next decade, except if we manage to take up maintenance for all our plugins again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we're getting to a point where fred can evolve less and less because of unmaintained plugin compatibility.

Until we have a solution for that (like introducing a shim that provides compatibility for legacy plugins), we'll have to live with that. Closing this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that’s a reality we have to live with.

The steps to move forward would be to first create an actual defined plugin API (which does not expose the full node) and when there are plugins using it and it’s proven itself to be sufficiently powerful, analyze all known plugins that do not use the new API which parts of fred they use. Then annotate all those places as @Published(plugins=["...", "..."]) or such to track when plugin updates enable removing those limitations.

I’m pretty sure Bombe already has ideas for such an API.


@Deprecated
public static final int DEBUG = LogLevel.DEBUG.ordinal();

@Deprecated
public static final int INTERNAL = LogLevel.NONE.ordinal();

/**
* Single global LoggerHook.
Expand All @@ -268,11 +240,6 @@ public synchronized static FileLoggerHook setupStdoutLogging(LogLevel level, Str
fh.start();
return fh;
}

@Deprecated
public synchronized static FileLoggerHook setupStdoutLogging(int level, String detail) throws InvalidThresholdException {
return setupStdoutLogging(LogLevel.fromOrdinal(level), detail);
}

/** Create a LoggerHookChain and set the global logger to be it. */
public synchronized static void setupChain() {
Expand Down Expand Up @@ -368,11 +335,6 @@ public synchronized static void logStatic(Object o, String s, LogLevel prio) {
public synchronized static void logStatic(Object o, String s, Throwable e, LogLevel prio) {
logger.log(o, s, e, prio);
}

@Deprecated
public synchronized static void logStatic(Object o, String s, int prio) {
logStatic(o, s, LogLevel.fromOrdinal(prio));
}

/**
* Log a message
Expand All @@ -395,16 +357,6 @@ public abstract void log(
String message,
Throwable e,
LogLevel priority);

@Deprecated
public void log(
Object o,
Class<?> source,
String message,
Throwable e,
int priority) {
log(o, source, message, e, LogLevel.fromOrdinal(priority));
}

/**
* Log a message.
Expand All @@ -414,11 +366,6 @@ public void log(
* LogLevel.NORMAL, LogLevel.MINOR, or LogLevel.DEBUG.
**/
public abstract void log(Object source, String message, LogLevel priority);

@Deprecated
public void log(Object source, String message, int priority) {
log(source, message, LogLevel.fromOrdinal(priority));
}

/**
* Log a message with an exception.
Expand All @@ -427,17 +374,10 @@ public void log(Object source, String message, int priority) {
* @param e Logs this exception with the message.
* @param priority The priority of the mesage, one of LogLevel.ERROR,
* LogLevel.NORMAL, LogLevel.MINOR, or LogLevel.DEBUG.
* @see #log(Object o, String message, int priority)
*/
public abstract void log(Object o, String message, Throwable e,
LogLevel priority);

@Deprecated
public void log(Object o, String message, Throwable e,
int priority) {
log(o, message, e, LogLevel.fromOrdinal(priority));
}

/**
* Log a message from static code.
* @param c The class where this message was generated.
Expand All @@ -446,11 +386,6 @@ public void log(Object o, String message, Throwable e,
* LogLevel.NORMAL, LogLevel.MINOR, or LogLevel.DEBUG.
*/
public abstract void log(Class<?> c, String message, LogLevel priority);

@Deprecated
public void log(Class<?> c, String message, int priority) {
log(c, message, LogLevel.fromOrdinal(priority));
}

/**
* Log a message from static code.
Expand All @@ -463,51 +398,25 @@ public void log(Class<?> c, String message, int priority) {
public abstract void log(Class<?> c, String message, Throwable e,
LogLevel priority);

@Deprecated
public void log(Class<?> c, String message, Throwable e,
int priority) {
log(c, message, e, LogLevel.fromOrdinal(priority));
}

/** Should this specific Logger object log a message concerning the
* given class with the given priority. */
public abstract boolean instanceShouldLog(LogLevel priority, Class<?> c);

@Deprecated
public boolean instanceShouldLog(int priority, Class<?> c) {
return instanceShouldLog(LogLevel.fromOrdinal(priority), c);
}

/** Would a message concerning an object of the given class be logged
* at the given priority by the global logger? */
public static boolean shouldLog(LogLevel priority, Class<?> c) {
return logger.instanceShouldLog(priority, c);
}

@Deprecated
public static boolean shouldLog(int priority, Class<?> c) {
return shouldLog(LogLevel.fromOrdinal(priority), c);
}

/** Would a message concerning the given object be logged
* at the given priority by the global logger? */
public static boolean shouldLog(LogLevel priority, Object o) {
return shouldLog(priority, o.getClass());
}

@Deprecated
public static boolean shouldLog(int priority, Object o) {
return shouldLog(LogLevel.fromOrdinal(priority), o);
}

/** Should this specific Logger object log a message concerning the
* given object with the given priority. */
public abstract boolean instanceShouldLog(LogLevel prio, Object o);

@Deprecated
public boolean instanceShouldLog(int prio, Object o) {
return instanceShouldLog(LogLevel.fromOrdinal(prio), o);
}

/**
* Changes the priority threshold.
Expand All @@ -516,11 +425,6 @@ public boolean instanceShouldLog(int prio, Object o) {
* The new threshhold
*/
public abstract void setThreshold(LogLevel thresh);

@Deprecated
public void setThreshold(int thresh) {
setThreshold(LogLevel.fromOrdinal(thresh));
}

/**
* Changes the priority threshold.
Expand All @@ -535,11 +439,6 @@ public void setThreshold(int thresh) {
* @return The currently used logging threshold
*/
public abstract LogLevel getThresholdNew();

@Deprecated
public int getThreshold() {
return getThresholdNew().ordinal();
}

/** Set the detailed list of thresholds. This allows to specify that
* we are interested in debug level logging for one class but are only
Expand Down Expand Up @@ -644,21 +543,11 @@ public synchronized static void globalAddHook(LoggerHook logger2) {
public synchronized static void globalSetThreshold(LogLevel i) {
logger.setThreshold(i);
}

@Deprecated
public synchronized static void globalSetThreshold(int i) {
logger.setThreshold(LogLevel.fromOrdinal(i));
}

/** What is the current global logging threshold? */
public synchronized static LogLevel globalGetThresholdNew() {
return logger.getThresholdNew();
}

@Deprecated
public synchronized static int globalGetThreshold() {
return globalGetThresholdNew().ordinal();
}

/** Remove a logger hook from the global logger hook chain. */
public synchronized static void globalRemoveHook(LoggerHook hook) {
Expand Down
1 change: 0 additions & 1 deletion src/freenet/support/LoggerHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void log(Object source, String message, LogLevel priority) {
* @param e Logs this exception with the message.
* @param priority The priority of the mesage, one of LogLevel.ERROR,
* LogLevel.NORMAL, LogLevel.MINOR, or LogLevel.DEBUG.
* @see #log(Object o, String message, int priority)
*/
@Override
public void log(Object o, String message, Throwable e,
Expand Down