static ByteBufferUtil() { Logger = InternalLoggerFactory.GetInstance(typeof(ByteBufferUtil)); string allocType = SystemPropertyUtil.Get("io.netty.allocator.type", "pooled"); allocType = allocType.Trim(); IByteBufferAllocator alloc; if ("unpooled".Equals(allocType, StringComparison.OrdinalIgnoreCase)) { alloc = UnpooledByteBufferAllocator.Default; Logger.Debug("-Dio.netty.allocator.type: {}", allocType); } else if ("pooled".Equals(allocType, StringComparison.OrdinalIgnoreCase)) { alloc = PooledByteBufferAllocator.Default; Logger.Debug("-Dio.netty.allocator.type: {}", allocType); } else if ("arraypooled".Equals(allocType, StringComparison.OrdinalIgnoreCase)) { alloc = ArrayPooledByteBufferAllocator.Default; Logger.Debug("-Dio.netty.allocator.type: {}", allocType); } else { alloc = PooledByteBufferAllocator.Default; Logger.Debug("-Dio.netty.allocator.type: pooled (unknown: {})", allocType); } DefaultAllocator = alloc; MaxBytesPerCharUtf8 = Encoding.UTF8.GetMaxByteCount(1); AsciiByteProcessor = new FindNonAscii(); }
/// <summary> /// Creates a new instance with the specified logger name. /// </summary> /// <param name="name">the name of the class to use for the logger</param> /// <param name="level">the log level</param> public XmppLoggingHandler(string name, LogLevel level) { Contract.Requires <ArgumentNullException>(name != null, $"{nameof(name)} cannot be null"); Logger = InternalLoggerFactory.GetInstance(name); Level = level; InternalLevel = level.ToInternalLevel(); }
static EmbeddedChannel() { LOCAL_ADDRESS = new EmbeddedSocketAddress(); REMOTE_ADDRESS = new EmbeddedSocketAddress(); EMPTY_HANDLERS = EmptyArray <IChannelHandler> .Instance; s_logger = InternalLoggerFactory.GetInstance <EmbeddedChannel>(); METADATA_NO_DISCONNECT = new ChannelMetadata(false); METADATA_DISCONNECT = new ChannelMetadata(true); }
public void ShouldGetInstance() { IInternalLogger one = InternalLoggerFactory.GetInstance("helloWorld"); IInternalLogger two = InternalLoggerFactory.GetInstance <string>(); Assert.NotNull(one); Assert.NotNull(two); Assert.NotSame(one, two); }
/// <summary> /// Creates a new instance with the specified logger name. /// </summary> /// <param name="name">the name of the class to use for the logger</param> /// <param name="level">the log level</param> public LoggingHandler(string name, LogLevel level) { if (name == null) { throw new NullReferenceException("name"); } this.Logger = InternalLoggerFactory.GetInstance(name); this.Level = level; this.InternalLevel = level.ToInternalLevel(); }
/// <summary> /// Creates a new instance with the specified logger name. /// </summary> /// <param name="type">the class type to generate the logger for</param> /// <param name="level">the log level</param> public LoggingHandler(Type type, LogLevel level) { if (type == null) { throw new NullReferenceException("type"); } this.Logger = InternalLoggerFactory.GetInstance(type); this.Level = level; this.InternalLevel = level.ToInternalLevel(); }
/// <summary> /// Creates a new instance with the specified logger name. /// </summary> /// <param name="type">the class type to generate the logger for</param> /// <param name="level">the log level</param> /// <param name="bufferFormat">the ByteBuf format</param> public LoggingHandler(Type type, LogLevel level, ByteBufferFormat bufferFormat) { if (type is null) { ThrowHelper.ThrowNullReferenceException(ExceptionArgument.type); } Logger = InternalLoggerFactory.GetInstance(type); Level = level; InternalLevel = level.ToInternalLevel(); BufferFormat = bufferFormat; }
static IDisposable SetupMockLogger(out Mock <IInternalLogger> loggerMock) { InternalLoggerFactory oldLoggerFactory = InternalLoggerFactory.DefaultFactory; var factoryMock = new Mock <InternalLoggerFactory>(MockBehavior.Strict); InternalLoggerFactory mockFactory = factoryMock.Object; loggerMock = new Mock <IInternalLogger>(MockBehavior.Strict); factoryMock.Setup(x => x.NewInstance("mock")).Returns(loggerMock.Object); InternalLoggerFactory.DefaultFactory = mockFactory; return(Disposable.Create(() => InternalLoggerFactory.DefaultFactory = oldLoggerFactory)); }
public void TestMockReturned() { Mock <ILogger> mock; using (SetupMockLogger(out mock)) { mock.Setup(x => x.IsEnabled(LogLevel.Trace)).Returns(true).Verifiable(); IInternalLogger logger = InternalLoggerFactory.GetInstance("mock"); Assert.True(logger.TraceEnabled); mock.Verify(x => x.IsEnabled(LogLevel.Trace), Times.Once); } }
public void TestMockReturned() { Mock <IInternalLogger> mock; using (SetupMockLogger(out mock)) { mock.SetupGet(x => x.TraceEnabled).Returns(true).Verifiable(); IInternalLogger logger = InternalLoggerFactory.GetInstance("mock"); Assert.Equal(logger, mock.Object); Assert.True(logger.TraceEnabled); mock.Verify(x => x.TraceEnabled, Times.Once); } }
static ResourceLeakDetector() { Logger = InternalLoggerFactory.GetInstance <ResourceLeakDetector>(); bool disabled = false; if (SystemPropertyUtil.Get("io.netty.noResourceLeakDetection") is object) { disabled = SystemPropertyUtil.GetBoolean("io.netty.noResourceLeakDetection", false); if (Logger.DebugEnabled) { Logger.Debug("-Dio.netty.noResourceLeakDetection: {}", disabled); } Logger.Warn( "-Dio.netty.noResourceLeakDetection is deprecated. Use '-D{}={}' instead.", PropLevel, DefaultLevel.ToString().ToLowerInvariant()); } var defaultLevel = disabled ? DetectionLevel.Disabled : DefaultLevel; // If new property name is present, use it string levelStr = SystemPropertyUtil.Get(PropLevel, defaultLevel.ToString()); if (!Enum.TryParse(levelStr, true, out DetectionLevel level)) { level = defaultLevel; } s_targetRecords = SystemPropertyUtil.GetInt(PropTargetRecords, DefaultTargetRecords); s_samplingInterval = SystemPropertyUtil.GetInt(PropSamplingInterval, DefaultSamplingInterval); Level = level; if (Logger.DebugEnabled) { Logger.Debug("-D{}: {}", PropLevel, level.ToString().ToLower()); Logger.Debug("-D{}: {}", PropTargetRecords, s_targetRecords); } }
public Http2FrameLogger(InternalLogLevel level, Type type) : this(level, InternalLoggerFactory.GetInstance(type)) { }
public Http2FrameLogger(InternalLogLevel level, string name) : this(level, InternalLoggerFactory.GetInstance(name)) { }
public Http2FrameLogger(InternalLogLevel level) : this(level, InternalLoggerFactory.GetInstance <Http2FrameLogger>()) { }