Example #1
0
 /// <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;
     }
 }
Example #2
0
 /// <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);
     }
 }
Example #3
0
        /// <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);
        }
Example #4
0
 /// <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);
     }
 }
Example #5
0
        /// <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);
            }
        }
Example #6
0
        /// <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);
                }
            }
        }
Example #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="collection"></param>
 public Enumerator(LayoutCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }
Example #8
0
 /// <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)
 {
 }
Example #9
0
 /// <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);
 }
Example #10
0
 /// <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);
 }
Example #11
0
 /// <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);
 }
Example #12
0
 /// <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);
 }
Example #13
0
 /// <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);
 }
Example #14
0
        /// <summary>
        /// 使用中のすべてのレイアウトをコレクションに追加します。
        /// </summary>
        public override void PopulateLayouts(LayoutCollection layouts)
        {
            base.PopulateLayouts(layouts);

            this.senderLayout.PopulateLayouts(layouts);
        }
Example #15
0
 /// <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);
 }
Example #16
0
 /// <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);
     }
 }
Example #17
0
 /// <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)
 {
 }
Example #18
0
 /// <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);
 }
Example #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public Enumerator(LayoutCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }