internal ChoBufferProfileEx(bool condition, string name, string filePath, ChoProfileIntializationAction mode, TextWriter streamWriter, string msg, IChoProfile outerProfile, bool register) { _condition = condition; _mode = mode; FilePath = String.IsNullOrEmpty(filePath) ? filePath : ChoString.ExpandProperties(filePath); TextWriter = streamWriter; //OuterProfile = outerProfile; if (String.IsNullOrEmpty(msg)) { msg = ChoProfile.GetDefaultMsg(ChoStackTrace.GetStackFrame(GetType().Namespace)); } msg = ChoString.ExpandProperties(msg); if (_condition) { _formattedMsg.AppendFormat("{0} {{{1}", msg, Environment.NewLine); } if (register) { ChoProfile.Register(name, this, ChoStackTrace.GetStackFrame(GetType().Namespace), false); } //if (OuterProfile is ChoProfileContainer) // ((ChoProfileContainer)OuterProfile).Add(this); }
//protected virtual void CloseBackingStore() //{ // if (_profileBackingStore != null) // _profileBackingStore.Stop(); //} protected override void Dispose(bool finalize) { try { StartIfNotStarted(); Clear(); if (_condition) { if (_name != ChoProfile.GLOBAL_PROFILE_NAME && _name != ChoProfile.NULL_PROFILE_NAME) { Write(String.Format("}} [{0}] <---{1}", Convert.ToString(DateTime.Now - _startTime), Environment.NewLine), _indent); } } Flush(); if (_registered) { ChoProfile.Unregister(this); } //CloseBackingStore(); } catch (Exception ex) { ChoTrace.Write(ex); } finally { IsDisposed = true; } }
public ChoProfile(bool condition, string msg, ChoProfile outerProfile) { _condition = condition; if (outerProfile != null) { _indent = outerProfile._indent + 1; } if (String.IsNullOrEmpty(msg)) { msg = GetDefaultMsg(ChoStackTrace.GetStackFrame()); } if (_condition) { if (ChoTraceSettings.Me.IndentProfiling) { ChoTrace.WriteLineIf(_condition, ChoStackTrace.GetStackFrame(typeof(ChoProfile)), String.Format("{0} {{", msg).Indent(_indent)); } else { ChoTrace.WriteLineIf(_condition, ChoStackTrace.GetStackFrame(typeof(ChoProfile)), String.Format("{0} {{", msg)); } } //if (outerProfile is ChoProfileContainer) // ((ChoProfileContainer)outerProfile).Add(this); }
protected override void Dispose(bool finalize) { if (!finalize) { return; } try { Clear(); if (!DelayedStartProfile || (DelayedStartProfile && Started)) { if (TraceOnDispose) { if (Condition) { string msg = Environment.NewLine + ToString().Indent(Indent - 1); if (!String.IsNullOrEmpty(FilePath)) { //if (Mode == ChoProfileIntializationAction.Roll) // ChoBufferProfile.RollNWriteLine(FilePath, msg); //else if (Mode == ChoProfileIntializationAction.Truncate) // ChoBufferProfile.CleanNWriteLine(FilePath, msg); //else // ChoBufferProfile.WriteLine(FilePath, msg); } else if (TextWriter != null) { TextWriter.Write(msg); TextWriter.Flush(); } else { ChoTrace.WriteIf(Condition, ChoStackTrace.GetStackFrame(GetType()), msg); } } } //else if (OuterProfile != null) // OuterProfile.Append(ToString()); } //ChoProfile.Unregister(CanDispose); //if (!finalize) // GC.SuppressFinalize(this); } catch (Exception ex) { ChoTrace.Write(ex); } finally { IsDisposed = true; } ChoProfile.Unregister(this); }
internal ChoBaseProfile(bool condition, string name, string msg, IChoProfile outerProfile, bool delayedStartProfile, string startActions, string stopActions) { _condition = condition; _name = name.IsNullOrWhiteSpace() || name == ChoProfile.DEFAULT_PROFILE_NAME ? String.Format("Profile_{0}".FormatString(ChoRandom.NextRandom())) : name; if (outerProfile != ChoProfile.NULL) { _outerProfile = outerProfile; } if (_outerProfile == null) { _profileBackingStore = ChoProfileBackingStoreManager.GetProfileBackingStore(name, startActions, stopActions); } _delayedStartProfile = delayedStartProfile; if (_condition) { if (!msg.IsNullOrEmpty()) { _msg = msg; } else if (!_name.IsNullOrEmpty()) { _msg = String.Format(_msg, _name); } else { _msg = ChoProfile.GetDefaultMsg(ChoStackTrace.GetStackFrame(GetType().Namespace)); } } if (ChoTraceSettings.Me.IndentProfiling) { if (outerProfile != null) { if (outerProfile.ProfilerName != ChoProfile.GLOBAL_PROFILE_NAME && outerProfile.ProfilerName != ChoProfile.NULL_PROFILE_NAME) { _indent = outerProfile.Indent + 1; } } } if (!_delayedStartProfile) { StartIfNotStarted(); } if (_outerProfile is ChoProfileContainer) { ((ChoProfileContainer)_outerProfile).Add(this); _parentProfile = outerProfile; } if (name != ChoProfile.GLOBAL_PROFILE_NAME && name != ChoProfile.NULL_PROFILE_NAME && name != ChoProfile.CURRENT_CONTEXT_PROFILE /* && outerProfile != null */) { ChoProfile.Register(this); _registered = true; } }
public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile) { IChoProfile profile = null; if (ChoProfile.TryGetProfile(_refProfileName, ref profile, null)) { return(profile); } else { throw new ChoApplicationException("{0} profile not exists.".FormatString(_refProfileName)); } }
internal static void FlushAll() { ChoProfile.DisposeAll(); //ChoStreamProfile.Shutdown(); foreach (TraceListener traceListener in Trace.Listeners) { if (traceListener == null) { continue; } traceListener.Flush(); } }
internal ChoBaseProfile(bool condition, string name, string msg, ChoBaseProfile outerProfile, bool delayedStartProfile, string startActions, string stopActions) { _condition = condition; _name = name; _outerProfile = outerProfile; if (_outerProfile == null) { _profileBackingStore = ChoProfileBackingStoreManager.GetProfileBackingStore(name, startActions, stopActions); } _delayedStartProfile = delayedStartProfile; if (_condition) { if (!msg.IsNullOrEmpty()) { _msg = msg; } else if (!_name.IsNullOrEmpty()) { _msg = String.Format(_msg, _name); } else { _msg = ChoProfile.GetDefaultMsg(ChoStackTrace.GetStackFrame(GetType().Namespace)); } } if (ChoTraceSettings.Me.IndentProfiling) { if (outerProfile != null) { _indent = outerProfile.Indent + 1; } } if (!_delayedStartProfile) { StartIfNotStarted(); } if (_outerProfile is ChoProfileContainer) { ((ChoProfileContainer)_outerProfile).Add(this); } }
public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile) { string message = null; if (!String.IsNullOrEmpty(Message)) { message = ChoPropertyManager.ExpandProperties(target, Message); } IChoProfile profile = null; if (ChoProfile.TryGetProfile(Name, ref profile, () => new ChoBufferProfile(Condition, Name, message, (ChoBaseProfile)outerProfile, false, StartActions, StopActions))) { return(profile); } else { return(null); } }
private static void Shutdown() { ChoProfile.DisposeAll(); if (_pbsDataChangeWatcher != null) { _pbsDataChangeWatcher.Dispose(); } _pbsDataChangeWatcher = null; ChoProfile.Default.Dispose(); _pbsStore.ForEach((keyValuePair) => { if (_profileBackingStopActionsCache.ContainsKey(keyValuePair.Key)) { keyValuePair.Value.Stop(_profileBackingStopActionsCache[keyValuePair.Key]); } }); //_profilerCache.Clear(); _profileBackingStopActionsCache.Clear(); }
public string AppendLine(string format, params object[] args) { return(ChoProfile.GetDefaultContext(_instance).AppendLine(format, args)); }
public string AppendLine(string msg) { return(ChoProfile.GetDefaultContext(_instance).AppendLine(msg)); }
public string AppendLineIf(bool condition, string format, params object[] args) { return(ChoProfile.GetDefaultContext(_instance).AppendLineIf(condition, format, args)); }
public string AppendLineIf(bool condition, string msg) { return(ChoProfile.GetDefaultContext(_instance).AppendLineIf(condition, msg)); }
public void Append(Exception ex) { ChoProfile.GetDefaultContext(_instance).Append(ex); }
public void Debug(Exception exception) { ((IChoTrace)ChoProfile.GetDefaultContext(_instance)).Debug(exception); }
public ChoProfile(string msg, ChoProfile outerProfile) : this(ChoTrace.ChoSwitch.TraceVerbose, msg, outerProfile) { }
public void WarnFormat(IFormatProvider provider, string format, params object[] args) { ((IChoTrace)ChoProfile.GetDefaultContext(_instance)).WarnFormat(provider, format, args); }
public void Warn(object message, Exception exception) { ((IChoTrace)ChoProfile.GetDefaultContext(_instance)).Warn(message, exception); }
public void Warn(object message) { ((IChoTrace)ChoProfile.GetDefaultContext(_instance)).Warn(message); }
public void InfoFormat(string format, params object[] args) { ((IChoTrace)ChoProfile.GetDefaultContext(_instance)).InfoFormat(format, args); }
public void Error(Exception exception) { ((IChoTrace)ChoProfile.GetDefaultContext(_instance)).Error(exception); }
public ChoBufferProfile(string name, string msg, IChoProfile outerProfile = null) : base(name, msg, outerProfile == null ? (name != ChoProfile.NULL_PROFILE_NAME && name != ChoProfile.DEFAULT_PROFILE_NAME ? ChoProfile.GetContext(new StackFrame(1)) : outerProfile) : outerProfile) { }
protected override void Dispose(bool finalize) { ChoProfile.ResetContext(); }
public ChoBufferProfile(string msg) : base(msg, ChoProfile.GetContext(new StackFrame(1))) { }
public void AppendIf(bool condition, Exception ex) { ChoProfile.GetDefaultContext(_instance).AppendIf(condition, ex); }
public void Warn(Exception exception) { ((IChoTrace)ChoProfile.GetDefaultContext(_instance)).Warn(exception); }
internal ChoBufferProfile(bool condition, string name, string msg) : base(condition, name, msg, ChoProfile.GetContext(new StackFrame(1))) { }