Exemplo n.º 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;
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="collection"></param>
 public Enumerator(LayoutCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 14
0
        /// <summary>
        /// 使用中のすべてのレイアウトをコレクションに追加します。
        /// </summary>
        public override void PopulateLayouts(LayoutCollection layouts)
        {
            base.PopulateLayouts(layouts);

            this.senderLayout.PopulateLayouts(layouts);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 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);
 }
Exemplo n.º 19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public Enumerator(LayoutCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }