77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using log4net.Appender;
|
|
using log4net.Core;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Voile.Common.Logging;
|
|
using Voile.Common.Logging.Sinks;
|
|
using WeifenLuo.WinFormsUI.Docking;
|
|
|
|
namespace Voile.DockContents
|
|
{
|
|
public partial class DockLog : DockContent, IVoileLogSink
|
|
{
|
|
private static VoileLog4netSink log4netSink;
|
|
private static VoileLogger logger;
|
|
public DockLog()
|
|
{
|
|
InitializeComponent();
|
|
|
|
richTextBox1.AllowDrop = true;
|
|
richTextBox1.DragEnter += RichTextBox1_DragEnter;
|
|
richTextBox1.DragDrop += RichTextBox1_DragDrop;
|
|
|
|
if (logger == null)
|
|
{
|
|
logger = VoileLogManager.GetLogger(this.GetType());
|
|
logger.Debug("Initalize DockLog");
|
|
}
|
|
}
|
|
|
|
public void Logger(string s)
|
|
{
|
|
richTextBox1.SuspendLayout();
|
|
richTextBox1.AppendText(s + Environment.NewLine);
|
|
richTextBox1.SelectionStart = richTextBox1.Text.Length;
|
|
richTextBox1.ScrollToCaret();
|
|
richTextBox1.ResumeLayout();
|
|
}
|
|
|
|
public void OnLogMessage(VoileLogMessage message)
|
|
{
|
|
Logger(String.Format("{0} {1} {2} - {3}", message.Timestamp, message.Level, message.SourceName, message.Message));
|
|
}
|
|
|
|
private bool initalized;
|
|
internal void InitalizeLogging()
|
|
{
|
|
if (initalized)
|
|
{
|
|
throw new Voile.Common.VoileException("Logging already initalized!");
|
|
}
|
|
|
|
log4netSink = new VoileLog4netSink();
|
|
log4netSink.Initalize();
|
|
VoileLogManager.GetInstance().AddSink(this);
|
|
|
|
initalized = true;
|
|
}
|
|
|
|
private void RichTextBox1_DragDrop(object? sender, DragEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void RichTextBox1_DragEnter(object? sender, DragEventArgs e)
|
|
{
|
|
}
|
|
|
|
|
|
}
|
|
}
|