/// <summary> /// Gets the collection of <see cref="Layout"/> objects that are used /// by this target. /// </summary> /// <returns>A <see cref="LayoutCollection"/> object which is a typed collection /// of <see cref="Layout"/> objects. The collection is cached and accumulated /// by calling <see cref="PopulateLayouts"/>.</returns> public LayoutCollection GetLayouts() { LayoutCollection lc = _allLayouts; if (lc == null) { lock (this) { lc = _allLayouts; if (lc == null) { lc = new LayoutCollection(); PopulateLayouts(lc); _allLayouts = lc; return lc; } else { return lc; } } } else { return lc; } }
/// <summary> /// Adds all layouts used by this target to the specified collection. /// </summary> /// <param name="layouts">The collection to add layouts to.</param> public override void PopulateLayouts(LayoutCollection layouts) { if (this.CompiledLayout != null) { this.CompiledLayout.PopulateLayouts(layouts); } }
/// <summary> /// Determines whether stack trace information should be gathered /// during log event processing. By default it calls <see cref="NLog.Layout.NeedsStackTrace" /> on /// the result of <see cref="GetLayouts()"/>. /// </summary> /// <returns>0 - don't include stack trace<br/>1 - include stack trace without source file information<br/>2 - include full stack trace</returns> protected internal virtual int NeedsStackTrace() { int nst = _needsStackTrace; if (nst == -1) { lock (this) { nst = _needsStackTrace; if (nst == -1) { int max = 0; LayoutCollection layouts = GetLayouts(); for (int i = 0; i < layouts.Count; ++i) { max = Math.Max(max, layouts[i].NeedsStackTrace()); if (max == 2) { break; } } nst = max; _needsStackTrace = nst; } } } return(nst); }
/// <summary> /// Adds the elements of another LayoutCollection to the end of this LayoutCollection. /// </summary> /// <param name="items"> /// The LayoutCollection whose elements are to be added to the end of this LayoutCollection. /// </param> public virtual void AddRange(LayoutCollection items) { foreach (ILayout item in items) { this.List.Add(item); } }
/// <summary> /// Gets the collection of <see cref="Layout"/> objects that are used /// by this target. /// </summary> /// <returns>A <see cref="LayoutCollection"/> object which is a typed collection /// of <see cref="Layout"/> objects. The collection is cached and accumulated /// by calling <see cref="PopulateLayouts"/>.</returns> public LayoutCollection GetLayouts() { LayoutCollection lc = _allLayouts; if (lc == null) { lock (this) { lc = _allLayouts; if (lc == null) { lc = new LayoutCollection(); PopulateLayouts(lc); _allLayouts = lc; return(lc); } else { return(lc); } } } else { return(lc); } }
/// <summary> /// Calls the <see cref="NLog.Layout.Precalculate"/> on each volatile layout /// used by this target. /// </summary> /// <param name="logEvent">The log event.</param> /// <remarks> /// A layout is volatile if it contains at least one <see cref="Layout"/> for /// which <see cref="LayoutRenderer.IsVolatile"/> returns true. /// </remarks> public void PrecalculateVolatileLayouts(LogEventInfo logEvent) { LayoutCollection layouts = GetLayouts(); for (int i = 0; i < layouts.Count; ++i) { if (layouts[i].IsVolatile()) { layouts[i].Precalculate(logEvent); } } }
/// <summary> /// /// </summary> /// <param name="collection"></param> public Enumerator(LayoutCollection collection) { this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator(); }
/// <summary> /// Adds all layouts used by this target to the specified collection. /// </summary> /// <param name="layouts">The collection to add layouts to.</param> public virtual void PopulateLayouts(LayoutCollection layouts) { }
/// <summary> /// Add this layout and all sub-layouts to the specified collection.. /// </summary> /// <param name="layouts">The collection of layouts.</param> public void PopulateLayouts(LayoutCollection layouts) { layouts.Add(this); }
/// <summary> /// Initializes a new instance of the LayoutCollection class, containing elements /// copied from another instance of LayoutCollection /// </summary> /// <param name="items"> /// The LayoutCollection whose elements are to be added to the new LayoutCollection. /// </param> public LayoutCollection(LayoutCollection items) { this.AddRange(items); }
/// <summary> /// Adds all layouts used by this target to the specified collection. /// </summary> /// <param name="layouts">The collection to add layouts to.</param> public override void PopulateLayouts(LayoutCollection layouts) { base.PopulateLayouts (layouts); WrappedTarget.PopulateLayouts(layouts); }
/// <summary> /// Adds all layouts used by this target to the specified collection. /// </summary> /// <param name="layouts">The collection to add layouts to.</param> public override void PopulateLayouts(LayoutCollection layouts) { if (this.CompiledLayout != null) this.CompiledLayout.PopulateLayouts(layouts); }
/// <summary> /// 使用中のすべてのレイアウトをコレクションに追加します。 /// </summary> public override void PopulateLayouts(LayoutCollection layouts) { base.PopulateLayouts(layouts); this.senderLayout.PopulateLayouts(layouts); }
/// <summary> /// Adds all layouts used by this target to the specified collection. /// </summary> /// <param name="layouts">The collection to add layouts to.</param> public override void PopulateLayouts(LayoutCollection layouts) { base.PopulateLayouts (layouts); _fileNameLayout.PopulateLayouts(layouts); }