static void fileWriterTest() { var fileWriter = new FileWriter("Log.txt"); fileWriter.ClearFile(); var formatter = new DefaultLogMessageFormatter(); LoggerFactory.AddAppender((logger, logLevel, message) => { var logMessage = formatter.FormatMessage(logger, logLevel, message); fileWriter.WriteLine(logMessage); }); }
void Awake() { _socket = new SocketAppender(); _defaultFormatter = new DefaultLogMessageFormatter(); _timestampFormatter = new TimestampFormatter(); _colorFormatter = new ColorCodeFormatter(); if (cacheLogsWhenNotConnected) { LoggerFactory.AddAppender(send); } }
void setupSOSMaxAppender() { var defaultFormatter = new DefaultLogMessageFormatter(); var socket = new SOSMaxAppender(); LoggerFactory.AddAppender(((logger, logLevel, message) => { message = defaultFormatter.FormatMessage(logger, logLevel, message); socket.Send(logLevel, message); })); socket.Connect(IPAddress.Loopback, 4444); }
static void consoleLogTest() { var defaultFormatter = new DefaultLogMessageFormatter(); var timestampFormatter = new TimestampFormatter(); var colorFormatter = new ColorCodeFormatter(); LoggerFactory.AddAppender((logger, logLevel, message) => { message = defaultFormatter.FormatMessage(logger, logLevel, message); message = timestampFormatter.FormatMessage(logger, logLevel, message); message = colorFormatter.FormatMessage(logLevel, message); Console.WriteLine(message); }); }
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); }
static void clientSocketTest() { var defaultFormatter = new DefaultLogMessageFormatter(); var socket = new SOSMaxAppender(); LoggerFactory.AddAppender(((logger, logLevel, message) => { message = defaultFormatter.FormatMessage(logger, logLevel, message); socket.Send(logLevel, message); })); socket.Connect(IPAddress.Loopback, 4444); Thread.Sleep(50); }
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); }
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); }
void when_created() { it["formats string"] = () => { var f = new DefaultLogMessageFormatter(); var logger = new Logger("MyLogger"); var message = f.FormatMessage(logger, LogLevel.Debug, "hi"); message.should_be("[DEBUG] MyLogger: hi"); }; it["pads logLevel"] = () => { var f = new DefaultLogMessageFormatter(); var logger = new Logger("MyLogger"); var message1 = f.FormatMessage(logger, LogLevel.Debug, "hi"); var message2 = f.FormatMessage(logger, LogLevel.Warn, "hi"); message1.should_be("[DEBUG] MyLogger: hi"); message2.should_be("[WARN] MyLogger: hi"); }; }
void Awake() { _fileWriter = new FileWriter(filePath); _defaultFormatter = new DefaultLogMessageFormatter(); _timestampFormatter = new TimestampFormatter(); }