public static TextWriter AsTextWriter(this IVerySimpleLineWriter writer) { var writerAsFromTextWriter = writer as IFromTextWriter; if (writerAsFromTextWriter != null) { return(writerAsFromTextWriter.OriginalTextWriter); } return(new VerySimpleLineWriter.ToTextWriter(writer)); }
private static void WriteLogLine(IVerySimpleLineWriter lineWriter, string operationName, string arguments) { Contract.Requires(lineWriter != null); var str = string.Format("Request #{3} received from user '{0}' [{1}]: {2}", System.Threading.Thread.CurrentPrincipal.Identity.Name, operationName, arguments, ClousotService.RequestId - 1); // -1 because by the time we are called we the instance is already created lineWriter.WriteLine(str.PrefixWithCurrentTime()); lineWriter.WriteLine(); }
public static TextWriter AsTextWriter(this IVerySimpleLineWriter writer, string encodingWebName) { var writerAsFromTextWriter = writer as IFromTextWriter; if (writerAsFromTextWriter != null) { if (writerAsFromTextWriter.OriginalTextWriter.Encoding.WebName != encodingWebName) { throw new ArgumentException("Encoding name different from original TextWriter encoding"); } return(writerAsFromTextWriter.OriginalTextWriter); } return(new VerySimpleLineWriter.ToTextWriterWithEncoding(writer, encodingWebName)); }
public static void WriteLine(this IVerySimpleLineWriter writer, string format, params object[] args) { writer.WriteLine(String.Format(format, args)); }
public static void WriteLine(this IVerySimpleLineWriter writer) { writer.WriteLine((string)null); }
public ToTextWriterWithEncoding(IVerySimpleLineWriter lineWriter, string encodingWebName) : base(lineWriter) { this.encoding = Encoding.GetEncoding(encodingWebName); }
public ToTextWriter(IVerySimpleLineWriter lineWriter) { this.lineWriter = lineWriter; }
public void AddLogger(IVerySimpleLineWriter lineWriter) { // OnMain is an custom event that we added // The intended behavior is to Log all the times the service is invoked this.ServiceInstance.OnMain += args => WriteLogLine(lineWriter, "Main", String.Join(" ", args)); }