public void WriteClientActivity(ClientActivity activity) { if (_writer != null && activity != null) { TimeSpan tspan = activity.EndTime - activity.StartTime; WriteSingleLine("activity [duration(ms) :" + tspan.TotalMilliseconds + " start_time :" + activity.StartTime.ToString(TIME_FORMAT) + " end_time :" + activity.EndTime.ToString(TIME_FORMAT) + "]"); if (activity.Activities != null) { for (int i = 0; i < activity.Activities.Count; i++) { MethodActivity mActivity = activity.Activities[i] as MethodActivity; if (mActivity != null) { int space2 = 40; string line = null; line = mActivity.Time.ToString(TIME_FORMAT) + ": " + mActivity.MethodName.PadRight(space2, ' ') + mActivity.Log; lock (_sync_mutex) { _writer.WriteLine(line); _writer.Flush(); } } } } WriteSingleLine("activity ends"); WriteSingleLine(""); } }
public void LogActivity(string method, string log) { MethodActivity mActivity = new MethodActivity(method, log); lock (this) { _activities.Add(mActivity); } }