Skip to content

Commit 671f781

Browse files
committed
formatting changes only
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
1 parent fb7b1ff commit 671f781

File tree

2 files changed

+247
-259
lines changed

2 files changed

+247
-259
lines changed

src/main/java/org/apache/log4j/net/SocketNode.java

Lines changed: 85 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -30,95 +30,96 @@
3030
// Contributors: Moses Hohman <mmhohman@rainbow.uchicago.edu>
3131

3232
/**
33-
Read {@link LoggingEvent} objects sent from a remote client using
34-
Sockets (TCP). These logging events are logged according to local
35-
policy, as if they were generated locally.
36-
37-
<p>For example, the socket node might decide to log events to a
38-
local file and also resent them to a second socket node.
39-
40-
@author Ceki G&uuml;lc&uuml;
41-
42-
@since 0.8.4
43-
*/
33+
* Read {@link LoggingEvent} objects sent from a remote client using Sockets
34+
* (TCP). These logging events are logged according to local policy, as if they
35+
* were generated locally.
36+
*
37+
* <p>
38+
* For example, the socket node might decide to log events to a local file and
39+
* also resent them to a second socket node.
40+
*
41+
* @author Ceki G&uuml;lc&uuml;
42+
*
43+
* @since 0.8.4
44+
*/
4445
public class SocketNode implements Runnable {
4546

46-
Socket socket;
47-
LoggerRepository hierarchy;
48-
ObjectInputStream ois;
47+
Socket socket;
48+
LoggerRepository hierarchy;
49+
ObjectInputStream ois;
4950

50-
static Logger logger = Logger.getLogger(SocketNode.class);
51+
static Logger logger = Logger.getLogger(SocketNode.class);
5152

52-
public SocketNode(Socket socket, LoggerRepository hierarchy) {
53-
this.socket = socket;
54-
this.hierarchy = hierarchy;
55-
try {
56-
ois = new ObjectInputStream(
57-
new BufferedInputStream(socket.getInputStream()));
58-
} catch(InterruptedIOException e) {
59-
Thread.currentThread().interrupt();
60-
logger.error("Could not open ObjectInputStream to "+socket, e);
61-
} catch(IOException e) {
62-
logger.error("Could not open ObjectInputStream to "+socket, e);
63-
} catch(RuntimeException e) {
64-
logger.error("Could not open ObjectInputStream to "+socket, e);
65-
}
66-
}
53+
public SocketNode(Socket socket, LoggerRepository hierarchy) {
54+
this.socket = socket;
55+
this.hierarchy = hierarchy;
56+
try {
57+
ois = new ObjectInputStream(new BufferedInputStream(socket.getInputStream()));
58+
} catch (InterruptedIOException e) {
59+
Thread.currentThread().interrupt();
60+
logger.error("Could not open ObjectInputStream to " + socket, e);
61+
} catch (IOException e) {
62+
logger.error("Could not open ObjectInputStream to " + socket, e);
63+
} catch (RuntimeException e) {
64+
logger.error("Could not open ObjectInputStream to " + socket, e);
65+
}
66+
}
6767

68-
//public
69-
//void finalize() {
70-
//System.err.println("-------------------------Finalize called");
71-
// System.err.flush();
72-
//}
68+
// public
69+
// void finalize() {
70+
// System.err.println("-------------------------Finalize called");
71+
// System.err.flush();
72+
// }
7373

74-
public void run() {
75-
LoggingEvent event;
76-
Logger remoteLogger;
74+
public void run() {
75+
LoggingEvent event;
76+
Logger remoteLogger;
7777

78-
try {
79-
if (ois != null) {
80-
while(true) {
81-
// read an event from the wire
82-
event = (LoggingEvent) ois.readObject();
83-
// get a logger from the hierarchy. The name of the logger is taken to be the name contained in the event.
84-
remoteLogger = hierarchy.getLogger(event.getLoggerName());
85-
//event.logger = remoteLogger;
86-
// apply the logger-level filter
87-
if(event.getLevel().isGreaterOrEqual(remoteLogger.getEffectiveLevel())) {
88-
// finally log the event as if was generated locally
89-
remoteLogger.callAppenders(event);
90-
}
91-
}
92-
}
93-
} catch(java.io.EOFException e) {
94-
logger.info("Caught java.io.EOFException closing conneciton.");
95-
} catch(java.net.SocketException e) {
96-
logger.info("Caught java.net.SocketException closing conneciton.");
97-
} catch(InterruptedIOException e) {
98-
Thread.currentThread().interrupt();
99-
logger.info("Caught java.io.InterruptedIOException: "+e);
100-
logger.info("Closing connection.");
101-
} catch(IOException e) {
102-
logger.info("Caught java.io.IOException: "+e);
103-
logger.info("Closing connection.");
104-
} catch(Exception e) {
105-
logger.error("Unexpected exception. Closing conneciton.", e);
106-
} finally {
107-
if (ois != null) {
108-
try {
109-
ois.close();
110-
} catch(Exception e) {
111-
logger.info("Could not close connection.", e);
112-
}
113-
}
114-
if (socket != null) {
115-
try {
116-
socket.close();
117-
} catch(InterruptedIOException e) {
118-
Thread.currentThread().interrupt();
119-
} catch(IOException ex) {
120-
}
121-
}
122-
}
123-
}
78+
try {
79+
if (ois != null) {
80+
while (true) {
81+
// read an event from the wire
82+
event = (LoggingEvent) ois.readObject();
83+
// get a logger from the hierarchy. The name of the logger is taken to be the
84+
// name contained in the event.
85+
remoteLogger = hierarchy.getLogger(event.getLoggerName());
86+
// event.logger = remoteLogger;
87+
// apply the logger-level filter
88+
if (event.getLevel().isGreaterOrEqual(remoteLogger.getEffectiveLevel())) {
89+
// finally log the event as if was generated locally
90+
remoteLogger.callAppenders(event);
91+
}
92+
}
93+
}
94+
} catch (java.io.EOFException e) {
95+
logger.info("Caught java.io.EOFException closing conneciton.");
96+
} catch (java.net.SocketException e) {
97+
logger.info("Caught java.net.SocketException closing conneciton.");
98+
} catch (InterruptedIOException e) {
99+
Thread.currentThread().interrupt();
100+
logger.info("Caught java.io.InterruptedIOException: " + e);
101+
logger.info("Closing connection.");
102+
} catch (IOException e) {
103+
logger.info("Caught java.io.IOException: " + e);
104+
logger.info("Closing connection.");
105+
} catch (Exception e) {
106+
logger.error("Unexpected exception. Closing conneciton.", e);
107+
} finally {
108+
if (ois != null) {
109+
try {
110+
ois.close();
111+
} catch (Exception e) {
112+
logger.info("Could not close connection.", e);
113+
}
114+
}
115+
if (socket != null) {
116+
try {
117+
socket.close();
118+
} catch (InterruptedIOException e) {
119+
Thread.currentThread().interrupt();
120+
} catch (IOException ex) {
121+
}
122+
}
123+
}
124+
}
124125
}

0 commit comments

Comments
 (0)