Inheritance: SocketAppenderBase
Exemple #1
0
        void Awake()
        {
            _socket = new SocketAppender();
            _defaultFormatter = new DefaultLogMessageFormatter();
            _timestampFormatter = new TimestampFormatter();
            _colorFormatter = new ColorCodeFormatter();

            if (cacheLogsWhenNotConnected) {
                LoggerFactory.AddAppender(send);
            }
        }
Exemple #2
0
        static void serverSocketTest()
        {
            var formatter = new DefaultLogMessageFormatter();
            var colorFormatter = new ColorCodeFormatter();
            var socket = new SocketAppender();
            LoggerFactory.AddAppender(((logger, logLevel, message) => {
                var logMessage = formatter.FormatMessage(logger, logLevel, message);
                var coloredLogMessage = colorFormatter.FormatMessage(logLevel, logMessage);
                socket.Send(logLevel, coloredLogMessage);
            }));

            socket.Listen(1234);
        }
Exemple #3
0
        static void clientSocketTest()
        {
            var formatter = new DefaultLogMessageFormatter();
            var colorFormatter = new ColorCodeFormatter();
            var socket = new SocketAppender();
            LoggerFactory.AddAppender(((logger, logLevel, message) => {
                var logMessage = formatter.FormatMessage(logger, logLevel, message);
                var coloredLogMessage = colorFormatter.FormatMessage(logLevel, logMessage);
                socket.Send(logLevel, coloredLogMessage);
            }));

            Log.Trace("History");
            socket.Connect(IPAddress.Loopback, 1234);
            Thread.Sleep(50);
        }
Exemple #4
0
        void setupExamaple()
        {
            // Setup appender
            var defaultFormatter = new DefaultLogMessageFormatter();
            var colorFormatter = new ColorCodeFormatter();
            var socket = new SocketAppender();
            LoggerFactory.AddAppender(((logger, logLevel, message) => {
                message = defaultFormatter.FormatMessage(logger, logLevel, message);
                message = colorFormatter.FormatMessage(logLevel, message);
                socket.Send(logLevel, message);
            }));

            // Setup as client
            socket.Connect(IPAddress.Loopback, 1234);

            // Or setup as server
            // socket.Listen(1234);
        }