Beispiel #1
0
        public static LogContext Open(Device device, LogSetting setting)
        {
            var intance = new LogContext();

            intance.Device  = device ?? throw new ArgumentNullException(nameof(device));
            intance.Setting = setting ?? throw new ArgumentNullException(nameof(setting));
            intance.StartInternal(false);
            return(intance);
        }
Beispiel #2
0
        string MakeLogcatCommand(LogSetting setting, bool resume)
        {
            var command = new StringBuilder("logcat");

            if (setting.Pid > 0)
            {
                command.Append($" --pid={this.Setting.Pid}");
            }

            if (setting.DefaultSlilent)
            {
                command.Append(" -s");
            }

            // 一時停止からの再開だったら前回の続きから、そうでなければ現在時間から
            var startAt = (resume && this.receivedLogs.Count > 0) ? this.receivedLogs.Last().Timestamp : this.Device.Date;

            if (startAt != DateTime.MinValue)
            {
                command.Append($" -T '{startAt.ToString("yyyy-MM-dd HH:mm:ss.fff")}'");
            }

            foreach (var pair in setting.PriorityEachTags)
            {
                if (pair.Value == Log.PriorityCode.None)
                {
                    command.Append($" {pair.Key}");
                }
                else
                {
                    command.Append($" {pair.Key}:{pair.Value}");
                }
            }

            return(command.ToString());
        }