/// <summary> /// initializes the Logging system with defined outputters /// </summary> /// <param name="staticInstance"> /// defines weather this log instance will be made to an singleton. /// Only one singleton(staticInstance) can exist otherwise an <see cref="AlreadyInitializedException"/> is thrown. /// </param> /// <param name="outputs">when left empty Log messages will be displayed only to the console</param> /// <param name="additionalFields">all <seealso cref="KeyValuePair{TKey,TValue}"/> will get added to every LogMessage processed.</param> public LOGInstance(bool staticInstance = false, IEnumerable <ILogOutput> outputs = null, IEnumerable <KeyValuePair <string, string> > additionalFields = null) { _disposeSingleton = staticInstance; if (staticInstance) { LOG.SetupSingleton(this); } if (additionalFields != null) { foreach (KeyValuePair <string, string> additionalField in additionalFields) { _additionalFields.Add(additionalField.Key, additionalField.Value); } } if (outputs == null) { ConsoleOutputter co = new ConsoleOutputter(); co.Initialize(); _outputter.Add(co); return; } foreach (ILogOutput logOutput in outputs) { logOutput.Initialize(); _outputter.Add(logOutput); } }
static void createLogger() { log = new Logger.Logger(); Logger.ConsoleOutputter cons = new ConsoleOutputter(); Logger.FileOutputter file = new FileOutputter(); log.SetLoggerLevel(Level.DEBUG); log.SetLoggerOutput(cons); log.SetLoggerOutput(file); }
static void Main() { bool isWorking = true; IOutputter outputter = new ConsoleOutputter(); IInputter inputter = new ConsoleInputter(); ValueArray array = new ValueArray(outputter); while (isWorking) { try { outputter.WriteLine(PreparedStrings.InputValue); foreach (var value in Enum.GetValues(typeof(InputType))) { string str = Format(PreparedStrings.EnumToString, (int)value, value); outputter.WriteLine(str); } string line = inputter.Read(); if (!Enum.TryParse(line, out InputType parsed)) { outputter.WriteLine(PreparedStrings.WrongInput); continue; } switch (parsed) { case InputType.WriteString: array.AddValue(inputter.Read()); break; case InputType.ShowResult: array.ShowResult(); break; case InputType.Exit: isWorking = false; break; default: outputter.WriteLine(PreparedStrings.WrongEnum); break; } } catch (Exception ex) { outputter.WriteLine(ex.Message); } finally { outputter.WriteLine(PreparedStrings.EndOfBlock); } } }
static void createLogger() { log = new Logger.Logger(); Logger.ConsoleOutputter cons = new ConsoleOutputter(); Logger.FileOutputter file = new FileOutputter(); SocketOutputter sockLogger = new SocketOutputter("localhost", 1800); log.SetLoggerOutput(sockLogger); log.SetLoggerLevel(Level.FATAL); log.SetLoggerOutput(cons); log.SetLoggerOutput(file); }
public void Start(object buffer) { ByteBufferOnArray byteBuffer = (ByteBufferOnArray)buffer; while (byteBuffer.HasAlmostOneChunk()) { processedChunksCount = 0; dict.Clear(); processingThreads.Clear(); for (int i = 0; i < threadCount; i++) { if (byteBuffer.HasAlmostOneChunk()) { try { byte[] chunk = byteBuffer.GetChunk(); long number = currentChunk; Thread thread = new Thread(() => ProcessChunk(chunk, number)); processingThreads.Add(thread); thread.Start(); } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } processedChunksCount++; currentChunk++; } } foreach (Thread thread in processingThreads) { thread.Join(); } int id = 0; foreach (byte[] chunk in GetOrderedChunks()) { ConsoleOutputter.Write(currentChunk - processedChunksCount + id, chunk); id++; } } if (byteBuffer.NotProcessedBytesCount() > 0) { ConsoleOutputter.Write(currentChunk, hasher.ComputeHash(byteBuffer.GetLastChunk())); } }
public void TestInit() { cons = new ConsoleOutputter(); }