blob: 5d97420f30a1d493d6412622a040b0a0fedf4183 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.logserver.net;
import com.yahoo.logserver.LogDispatcher;
import com.yahoo.io.Connection;
import com.yahoo.io.Listener;
import com.yahoo.io.ConnectionFactory;
import com.yahoo.logserver.net.control.Levels;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.nio.channels.SocketChannel;
/**
* @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
*/
public class LogConnectionFactory implements ConnectionFactory
{
private static final Logger log
= Logger.getLogger(LogConnectionFactory.class.getName());
final LogDispatcher dispatcher;
final Levels defaultLogLevels;
public LogConnectionFactory (LogDispatcher dispatcher) {
this.dispatcher = dispatcher;
defaultLogLevels = Levels.parse(System.getProperty("logserver.default.loglevels", ""));
}
public Connection newConnection (SocketChannel socket, Listener listener) {
if (log.isLoggable(Level.FINE)) {
log.fine("New connection: " + socket);
}
return new LogConnection(socket,
listener,
dispatcher,
(Levels)defaultLogLevels.clone());
}
}
|