Exemplo n.º 1
0
        /// <summary>
        /// Writes a text entry to the log.
        /// </summary>
        /// <param name="type">The type of message.</param>
        /// <param name="message">The message for this entry.</param>
        /// <param name="details">Optional detailed information for this entry.</param>
        /// <param name="verbosity">The verbosity level of this entry.</param>
        public void WriteEntry(EntryType type, string message, string details, EntryVerbosity verbosity)
        {
            LogEntry entry = new LogEntry();

            entry.Time            = DateTime.UtcNow;
            entry.Message         = message;
            entry.ExtendedMessage = details;
            entry.Body            = BodyType.Text;
            entry.Type            = type;
            entry.Verbosity       = verbosity;

            EventHandler <LogEventArgs> handler = null;

            if (type == EntryType.Warning)
            {
                handler = BeforeWarningIsPosted;
            }
            else if (type == EntryType.Error)
            {
                handler = BeforeErrorIsPosted;
            }

            if (handler != null)
            {
                handler(this, new LogEventArgs(entry));
            }

            if (entry.Enabled)
            {
                entry.ToXml(_writer);
                _writer.Flush();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes a link log entry to the current log, if any.
        /// </summary>
        /// <param name="link">The link to log.</param>
        /// <param name="message">The message for this entry.</param>
        /// <param name="details">Optional detailed information for this entry.</param>
        /// <param name="verbosity">The verbosity level of this entry.</param>
        public static void Link(string link, string message, string details, EntryVerbosity verbosity)
        {
            Log log = _currentLog;

            if (log != null)
            {
                log.WriteLinkEntry(link, message, details, verbosity);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Writes an image entry to the current log, if any.
        /// </summary>
        /// <param name="image">The image to log.</param>
        /// <param name="message">The message for this entry.</param>
        /// <param name="details">Optional detailed information for this entry.</param>
        /// <param name="verbosity">The verbosity level of this entry.</param>
        public static void Image(Image image, string message, string details, EntryVerbosity verbosity)
        {
            Log log = _currentLog;

            if (log != null)
            {
                log.WriteImageEntry(image, message, details, verbosity);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Writes an error log entry to the current log, if any.
        /// </summary>
        /// <param name="message">The message for this entry.</param>
        /// <param name="details">Optional detailed information for this entry.</param>
        /// <param name="verbosity">The verbosity level of this entry.</param>
        public static void Error(string message, string details, EntryVerbosity verbosity)
        {
            Log log = _currentLog;

            if (log != null)
            {
                log.WriteEntry(EntryType.Error, message, details, verbosity);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Writes a link entry to the log.
        /// </summary>
        /// <param name="link">The link to log.</param>
        /// <param name="message">The message for this entry.</param>
        /// <param name="details">Optional detailed information for this entry.</param>
        /// <param name="verbosity">The verbosity level of this entry.</param>
        public void WriteLinkEntry(string link, string message, string details, EntryVerbosity verbosity)
        {
            LogEntry entry = new LogEntry();

            entry.Time            = DateTime.UtcNow;
            entry.Message         = message;
            entry.ExtendedMessage = details;
            entry.Body            = BodyType.Link;
            entry.Type            = EntryType.Info;
            entry.Verbosity       = verbosity;
            entry.Link            = link;

            entry.ToXml(_writer);
            _writer.Flush();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Writes an image entry to the log.
        /// </summary>
        /// <param name="image">The image to log.</param>
        /// <param name="message">The message for this entry.</param>
        /// <param name="details">Optional detailed information for this entry.</param>
        /// <param name="verbosity">The verbosity level of this entry.</param>
        public void WriteImageEntry(Image image, string message, string details, EntryVerbosity verbosity)
        {
            LogEntry entry = new LogEntry();

            entry.Time            = DateTime.UtcNow;
            entry.Message         = message;
            entry.ExtendedMessage = details;
            entry.Body            = BodyType.Picture;
            entry.Type            = EntryType.Info;
            entry.Verbosity       = verbosity;

            string imageFile = Path + @"\image" + _imageCount.ToString(CultureInfo.InvariantCulture) + ".png";

            image.Save(imageFile, System.Drawing.Imaging.ImageFormat.Png);
            entry.Link = imageFile;
            _imageCount++;

            entry.ToXml(_writer);
            _writer.Flush();
        }
Exemplo n.º 7
0
        internal EntryStyle(EntryVerbosity verbosity)
        {
            switch (verbosity)
            {
            case EntryVerbosity.Internal:
                fgColor = Color.DarkGray;
                break;

            case EntryVerbosity.Debug:
                fgColor = Color.Blue;
                break;

            case EntryVerbosity.Normal:
                break;

            case EntryVerbosity.Critical:
                fgColor   = Color.Red;
                fontStyle = FontStyle.Bold;
                break;

            default:
                break;
            }
        }