Esempio n. 1
0
        /// <summary> Dumps the Log messages this chute is holding into a new chute</summary>
        /// <param name="newChute">
        /// </param>

        public virtual void TransferTo(ILogChute newChute)
        {
            lock (this)
            {
                if (!transferring && !(pendingMessages.Count == 0))
                {
                    // let the other methods know what's up
                    transferring = true;

                    // iterate and Log each individual message...

                    for (System.Collections.IEnumerator i = pendingMessages.GetEnumerator(); i.MoveNext();)
                    {
                        System.Object[] data    = (System.Object[])i.Current;
                        int             level   = ((System.Int32)data[0]);
                        System.String   message = (System.String)data[1];
                        if (data.Length == 2)
                        {
                            newChute.Log(level, message);
                        }
                        else
                        {
                            newChute.Log(level, message, (System.Exception)data[2]);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary> Updates the LogChute wrapped by this LogMessage instance.</summary>
 /// <param name="chute">The new value for the Log chute.
 /// </param>
 protected internal virtual void SetLogChute(ILogChute chute)
 {
     if (chute == null)
     {
         throw new System.NullReferenceException("The LogChute cannot be set to null!");
     }
     this.chute = chute;
 }
Esempio n. 3
0
        /// <summary> Update the Log instance with the appropriate ILogChute and other
        /// settings determined by the RuntimeServices.
        /// </summary>
        /// <param name="Log">
        /// </param>
        /// <param name="rsvc">
        /// </param>
        /// <throws>  Exception </throws>
        /// <since> 1.5
        /// </since>
        public static void UpdateLog(Log log, IRuntimeServices rsvc)
        {
            // create a new ILogChute using the RuntimeServices
            ILogChute newLogChute = CreateLogChute(rsvc);
            ILogChute oldLogChute = log.GetLogChute();

            // pass the new ILogChute to the Log first,
            // (if the old was a HoldingLogChute, we don't want it
            //  to accrue new messages during the transfer below)
            log.SetLogChute(newLogChute);

            // If the old ILogChute was the pre-Init logger,
            // dump its messages into the new system.
            if (oldLogChute is HoldingLogChute)
            {
                HoldingLogChute hlc = (HoldingLogChute)oldLogChute;
                hlc.TransferTo(newLogChute);
            }
        }
Esempio n. 4
0
 /// <seealso cref="org.apache.velocity.runtime.Log.LogMessage.setLogChute(org.apache.velocity.runtime.Log.LogChute)">
 /// </seealso>
 protected internal override void SetLogChute(ILogChute newLogChute)
 {
     throw new System.NotSupportedException("RuntimeLoggerLog does not support this method.");
 }
Esempio n. 5
0
 /// <summary> Creates a new LogMessage that wraps the specified LogChute.</summary>
 /// <param name="chute">
 /// </param>
 public Log(ILogChute chute)
 {
     SetLogChute(chute);
 }