Esempio n. 1
0
        /// <summary>
        /// Formats the message.
        /// </summary>
        /// <param name="log"></param>
        /// <param name="buf"></param>
        /// <returns></returns>
        public string Format(ILog log, LogLevel level, LogArgs args)
        {
            StringBuilder builder = new StringBuilder();

            AppendDateTime(builder);
            builder.Append(InterpunctSep);
            AppendLevelName(builder, level);
            builder.Append(InterpunctSep);
            AppendThreadName(builder);
            builder.Append(InterpunctSep);
            builder.Append(log.Name);

            builder.Append(" ");
            while (builder.Length % 4 != 0)
            {
                builder.Append(" ");
            }
            builder.Append(args.Message);

            // ex?
            if (args.HasException)
            {
                builder.Append("\r\n\t");
                builder.Append(args.Exception);
            }

            // return...
            return(builder.ToString());
        }
Esempio n. 2
0
        public string Format(ILog log, BootFX.Common.Management.LogLevel level, LogArgs args)
        {
            // mbr - 22-05-2008 - changed this to add date/time, because that's always handy.

//			// mbr - 20-08-2006 - wasn't handling exceptions...
//			if(ex == null)
//				return buf;
//			else
//				return string.Format("{0}\r\n\t{1}", buf, ex);

            // builder...
            StringBuilder builder = new StringBuilder();

            DefaultLogFormatter.AppendDateTime(builder);
            builder.Append(" | ");
            builder.Append(args.Message);

            // ex?
            if (args.HasException)
            {
                builder.Append("\r\n\t");
                builder.Append(args.Exception);
            }

            // return...
            return(builder.ToString());
        }
Esempio n. 3
0
File: Log.cs Progetto: radtek/BootFX
        /// <summary>
        /// Logs the given message.
        /// </summary>
        /// <param name="level"></param>
        /// <param name="buf"></param>
        /// <returns></returns>
        internal void LogMessage(LogLevel level, string buf, Exception exception = null, Action <LogArgs> options = null)
        {
            var args = new LogArgs(buf, exception);

            if (options != null)
            {
                options(args);
            }
            this.LogMessage(level, args);
        }
Esempio n. 4
0
 public string Format(ILog log, BootFX.Common.Management.LogLevel level, LogArgs args)
 {
     if (args.HasException)
     {
         return(string.Format("{0}\r\n\r\nException:\r\n{1}", args.Message, args.Exception));
     }
     else
     {
         return(args.Message + "\r\n\r\n(No exception)");
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="level"></param>
        /// <param name="unformattedBuf"></param>
        /// <param name="exception"></param>
        /// <param name="formattedBuf"></param>
        public LogData(LogLevel level, LogArgs args, string formattedBuf)
        {
            _level          = level;
            _unformattedBuf = args.Message;
            _exception      = args.Exception;
            this.System     = args.System;
            this.Category   = args.Category;
            _formattedBuf   = formattedBuf;
            this.Color      = args.Color;
            this.HasColor   = args.HasColor;

            // mbr - 07-11-2005 - other stuff...
            _dateTime = DateTime.UtcNow;
            //_entryAssembly = Assembly.GetEntryAssembly();

            // mbr - 08-02-2008 - changed to use low-trust and shared thread method...
            if (Runtime.IsStarted && !(Runtime.Current.IsLowTrust))
            {
                _threadId = Runtime.GetCurrentThreadId();
            }
            else
            {
                _threadId = 0;
            }

            // set...
            _isThreadPoolThread = Thread.CurrentThread.IsThreadPoolThread;
            _threadName         = GetThreadName();

            //// user...
            //IPrincipal principal = Thread.CurrentPrincipal;
            //if(principal != null && principal.Identity != null && principal.Identity.IsAuthenticated)
            //	_windowsUsername = principal.Identity.Name;

            //// mbr - 07-11-2005 - http...
            //HttpContext context = HttpContext.Current;
            //if(context != null && context.Request != null)
            //{
            //	_isHttpRequest = true;
            //	_httpUrl = context.Request.Url.LocalPath;
            //	_httpQueryString = context.Request.Url.Query;
            //}
        }
Esempio n. 6
0
File: Log.cs Progetto: radtek/BootFX
        private void LogMessage(LogLevel level, LogArgs args)
        {
            if (this.IsLevelEnabled(level) == false)
            {
                return;
            }

            // walk the appenders...
            foreach (Appender appender in this.Appenders)
            {
                try
                {
                    appender.Append(level, args);
                }
                catch (Exception ex)
                {
                    LogManager.InternalError(string.Format("Failed to append to '{0}'.", appender), ex);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Appends a message.
        /// </summary>
        /// <param name="buf"></param>
        public void Append(LogLevel level, LogArgs args)
        {
            if (Log == null)
            {
                throw new InvalidOperationException("Log is null.");
            }
            if (Formatter == null)
            {
                throw new InvalidOperationException("Formatter is null.");
            }

            // are we supported for this level?
            if (this.IsLevelEnabled(level))
            {
                // format it...
                string formatted = this.Formatter.Format(this.Log, level, args);

                // package it...
                LogData data = new LogData(level, args, formatted);

                // mbr - 07-11-2005 - if the appender supports lazy writing, do it in a background thread...
                //if(this.LazyWrite && Runtime.IsStarted)
                //{
                //    // do we have the service?
                //    if(Runtime.Current.InternalManagementService == null)
                //        throw new InvalidOperationException("Runtime.Current.InternalManagementService is null.");
                //    if(Runtime.Current.InternalManagementService.LazyLoggingEngine == null)
                //        throw new InvalidOperationException("Runtime.Current.InternalManagementService.LazyLoggingEngine is null.");

                //    // queue it...
                //    Runtime.Current.InternalManagementService.LazyLoggingEngine.Enqueue((Appender)this, data);
                //}
                //else
                {
                    // write it...
                    this.DoAppend(data);
                }
            }
        }
Esempio n. 8
0
        public string Format(ILog log, BootFX.Common.Management.LogLevel level, LogArgs args)
        {
            StringBuilder builder = new StringBuilder();

            DefaultLogFormatter.AppendDateTime(builder);
            builder.Append(" | ");
            DefaultLogFormatter.AppendLevelName(builder, level);
            builder.Append(" | ");
            DefaultLogFormatter.AppendThreadName(builder);
            builder.Append(" | ");
            builder.Append(args.Message);

            // ex?
            if (args.HasException)
            {
                builder.Append("\r\n\t");
                builder.Append(args.Exception);
            }

            // return...
            return(builder.ToString());
        }
Esempio n. 9
0
File: Log.cs Progetto: radtek/BootFX
 public void Trace(LogArgs args)
 {
     this.LogMessage(LogLevel.Trace, args);
 }
Esempio n. 10
0
 public void Trace(LogArgs args)
 {
 }
Esempio n. 11
0
 public void Fatal(LogArgs args)
 {
     // TODO:  Add NullLog.Fatal implementation
 }
Esempio n. 12
0
 public void Error(LogArgs args)
 {
     // TODO:  Add NullLog.Error implementation
 }
Esempio n. 13
0
 public void Warn(LogArgs args)
 {
     // TODO:  Add NullLog.Warn implementation
 }
Esempio n. 14
0
 public void Info(LogArgs args)
 {
     // TODO:  Add NullLog.Info implementation
 }
Esempio n. 15
0
 public void Debug(LogArgs args)
 {
     // TODO:  Add NullLog.Debug implementation
 }
Esempio n. 16
0
File: Log.cs Progetto: radtek/BootFX
 public void Debug(LogArgs args)
 {
     this.LogMessage(LogLevel.Debug, args);
 }
Esempio n. 17
0
File: Log.cs Progetto: radtek/BootFX
 public void Info(LogArgs args)
 {
     this.LogMessage(LogLevel.Info, args);
 }
Esempio n. 18
0
File: Log.cs Progetto: radtek/BootFX
 public void Fatal(LogArgs args)
 {
     this.LogMessage(LogLevel.Fatal, args);
 }
Esempio n. 19
0
File: Log.cs Progetto: radtek/BootFX
 public void Error(LogArgs args)
 {
     this.LogMessage(LogLevel.Error, args);
 }
Esempio n. 20
0
File: Log.cs Progetto: radtek/BootFX
 public void Warn(LogArgs args)
 {
     this.LogMessage(LogLevel.Warn, args);
 }