public IObservable <string> Logcat(LogcatOptions options = LogcatOptions.None, LogOutputFormat format = LogOutputFormat.Brief, CancellationToken cancellationToken = default(CancellationToken), params LogFilter[] filters) { using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken)) { string formatString = format == LogOutputFormat.Brief ? string.Empty : string.Format("-v {0}", format.ToString().ToLower()); string filtersString = filters.Aggregate("", (acc, f) => acc + " " + f.ToString()); var process = new Adb(this, "logcat {0} {1} {2}", options.GenerateString(), formatString, filtersString).CreateProcess(AdbExecutablePath, cts, 0, false); process.RunAsync(cts.Token); return(process.Output); } }
/// <summary> /// Instantiate a new logger with the specified options. /// </summary> /// <param name="outputVerbosity">Minimum verbosity level message that will be output</param> /// <param name="outputOption">Mask of options for output</param> /// <param name="logFormat">Output format for Logger output</param> public Logger(VerbosityLevel outputVerbosity, LogOutputOption outputOption = LogOutputOption.DebugTrace, LogOutputFormat logFormat = LogOutputFormat.MessageOnly) { setVerbosity(outputVerbosity); this.outputFormat = logFormat; this.outputOptions = outputOption; }
/// <summary> /// Set the custom format to format for logging and specify format. /// </summary> /// <param name="format"> /// <para>String format for output using the composite format string rules (DateTime and Time formats can be specified). Output parts as follows:</para> /// <para>{0} - Message, /// {1} - DateTime message passed to Logger, /// {2} - Time message passed to Logger, /// {3} - Calling Function Name, /// {4} - Calling Source File Path, /// {5} - Calling Source Line Number, /// {6} - Process ID</para> /// </param> /// <seealso cref="https://msdn.microsoft.com/en-us/library/txafckwd(v=vs.110).aspx"/> public bool setFormatCustom(string format) { try { string.Format(format, "message", DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, "caller()", "c:\\caller.cs", 13, 1313); } catch(FormatException) { return false; } this.outputFormat = LogOutputFormat.Custom; this.dictOutputFormats[LogOutputFormat.Custom] = format; return true; }