// Triton.Common.LogUtilities.CustomLogger
// Token: 0x04000BD8 RID: 3032
private Level level_0 = Level.All;
// Token: 0x04000BD9 RID: 3033
private Level level_1 = Level.Emergency;
// Token: 0x06001779 RID: 6009 RVA: 0x000D3D08 File Offset: 0x000D1F08
public CustomLogger(string path, string prefix, Level minLevel, Level maxLevel)
{
this.string_0 = prefix;
this.level_0 = (minLevel ?? Level.All);
this.level_1 = (maxLevel ?? Level.Emergency);
Directory.CreateDirectory(path);
PatternLayout patternLayout = new PatternLayout("%-4utcdate [%thread] %-5level %logger{1} %ndc - %message%newline");
DateTime now = DateTime.Now;
this.FileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), string.Format("{6}\\{7} {5} {0:0000}-{1:00}-{2:00} {3:00}.{4:00}.txt", new object[]
{
now.Year,
now.Month,
now.Day,
now.Hour,
now.Minute,
Process.GetCurrentProcess().Id,
path,
this.string_0
}));
FileAppender fileAppender = new FileAppender
{
File = this.FileName,
Layout = patternLayout,
LockingModel = new FileAppender.MinimalLock()
};
fileAppender.AddFilter(new LevelRangeFilter
{
LevelMin = this.level_0,
LevelMax = this.level_1,
AcceptOnMatch = true
});
patternLayout.ActivateOptions();
fileAppender.ActivateOptions();
AsyncAppender asyncAppender = new AsyncAppender();
asyncAppender.AddAppender(fileAppender);
asyncAppender.ActivateOptions();
Hierarchy hierarchy = (Hierarchy)LogManager.CreateRepository(this.string_0);
hierarchy.Root.AddAppender(asyncAppender);
hierarchy.Configured = true;
}
// Triton.Common.LogUtilities.CustomLogger
// Token: 0x0600177C RID: 6012 RVA: 0x000D3F1C File Offset: 0x000D211C
public void AddWpfListener(ScrollViewer scrollViewer, RichTextBox rtbLog)
{
PatternLayout patternLayout = new PatternLayout("%message");
this.wpfRtfAppender_0 = new WpfRtfAppender(scrollViewer, rtbLog)
{
Layout = patternLayout
};
LevelRangeFilter levelRangeFilter = new LevelRangeFilter();
levelRangeFilter.LevelMin = this.level_0;
levelRangeFilter.LevelMax = this.level_1;
this.wpfRtfAppender_0.AddFilter(levelRangeFilter);
patternLayout.ActivateOptions();
this.wpfRtfAppender_0.ActivateOptions();
AsyncAppender asyncAppender = new AsyncAppender();
asyncAppender.AddAppender(this.wpfRtfAppender_0);
asyncAppender.ActivateOptions();
((Hierarchy)LogManager.GetRepository(this.string_0)).Root.AddAppender(asyncAppender);
}

如何把日志输出到MainWindow

// Hearthbuddy.Windows.MainWindow
// Token: 0x0400014B RID: 331
private bool bool_0 = true;
// Token: 0x04000150 RID: 336
private readonly Stopwatch stopwatch_0 = new Stopwatch();
// Token: 0x060001FE RID: 510 RVA: 0x00003C20 File Offset: 0x00001E20
public MainWindow()
{
this.InitializeComponent();
Logger.AddWpfListener(this.scrollViewer_0, this.richTextBox_0);
}
// Triton.Common.LogUtilities.Logger
// Token: 0x06001782 RID: 6018 RVA: 0x00010FE5 File Offset: 0x0000F1E5
public static void AddWpfListener(ScrollViewer scrollViewer, RichTextBox rtbLog)
{
Logger.customLogger_0.AddWpfListener(scrollViewer, rtbLog);
}
// Triton.Common.LogUtilities.CustomLogger
// Token: 0x0600177C RID: 6012 RVA: 0x000D3F24 File Offset: 0x000D2124
public void AddWpfListener(ScrollViewer scrollViewer, RichTextBox rtbLog)
{
PatternLayout patternLayout = new PatternLayout("%date{yyyy-MM-dd HH:mm:ss.fffzzz} [%thread] %-5level %logger - %message%newline");
this.wpfRtfAppender_0 = new WpfRtfAppender(scrollViewer, rtbLog)
{
Layout = patternLayout
};
LevelRangeFilter levelRangeFilter = new LevelRangeFilter();
levelRangeFilter.LevelMin = this.level_0;
levelRangeFilter.LevelMax = this.level_1;
this.wpfRtfAppender_0.AddFilter(levelRangeFilter);
patternLayout.ActivateOptions();
this.wpfRtfAppender_0.ActivateOptions();
AsyncAppender asyncAppender = new AsyncAppender();
asyncAppender.AddAppender(this.wpfRtfAppender_0);
asyncAppender.ActivateOptions();
((Hierarchy)LogManager.GetRepository(this.string_0)).Root.AddAppender(asyncAppender);
}

输出日志的颜色控制

// Triton.Common.LogUtilities.WpfRtfAppender
// Token: 0x060017AA RID: 6058 RVA: 0x000D40E4 File Offset: 0x000D22E4
private void method_0(object sender, EventArgs e)
{
try
{
this.dispatcherTimer_0.Stop();
SolidColorBrush solidColorBrush = this.InfoBrush;
StringBuilder stringBuilder = new StringBuilder();
Action<StringBuilder, SolidColorBrush> action = new Action<StringBuilder, SolidColorBrush>(this.method_1);
if (this.paragraph_0 == null)
{
this.richTextBox_0.Document.Blocks.Clear();
this.paragraph_0 = new Paragraph();
this.paragraph_0.Margin = new Thickness(0.0);
this.richTextBox_0.Document.Blocks.Add(this.paragraph_0);
}
if (this.int_0 >= )
{
this.paragraph_0.Inlines.Clear();
this.int_0 = ;
}
LoggingEvent loggingEvent;
while (this.concurrentQueue_0.TryDequeue(out loggingEvent))
{
loggingEvent.Fix = FixFlags.All;
string value = base.RenderLoggingEvent(loggingEvent);
string name = loggingEvent.Level.Name;
SolidColorBrush solidColorBrush2;
if (!(name == "DEBUG"))
{
if (!(name == "ERROR"))
{
if (!(name == "WARN"))
{
solidColorBrush2 = this.InfoBrush;
}
else
{
solidColorBrush2 = this.WarnBrush;
}
}
else
{
solidColorBrush2 = this.ErrorBrush;
}
}
else
{
solidColorBrush2 = this.DebugBrush;
}
if (!object.Equals(solidColorBrush2, solidColorBrush))
{
action(stringBuilder, solidColorBrush);
stringBuilder.Clear();
solidColorBrush = solidColorBrush2;
}
stringBuilder.AppendLine(value);
this.int_0++;
}
if (stringBuilder.Length != )
{
action(stringBuilder, solidColorBrush);
this.int_0++;
}
if (this.scrollViewer_0.ScrollableHeight.Equals(this.scrollViewer_0.ContentVerticalOffset))
{
this.scrollViewer_0.ScrollToEnd();
}
}
finally
{
this.dispatcherTimer_0.Start();
}
}

HearthBuddy 日志模块的更多相关文章

  1. 【腾讯Bugly干货分享】微信mars 的高性能日志模块 xlog

    本文来自于腾讯bugly开发者社区,未经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/581c2c46bef1702a2db3ae53 Dev Club 是一个交流移动 ...

  2. Python 日志模块 logging通过配置文件方式使用

    vim logger_config.ini[loggers]keys=root,infoLogger,errorlogger [logger_root]level=DEBUGhandlers=info ...

  3. 搭建一套自己实用的.net架构(2)【日志模块-log4net】

    先谈谈简单的模块,日志.在系统中日志模块是必须的,什么系统日志,操作日志,调试日志.这里用的是log4net. 对log4net还不熟悉的小伙伴们赶快去搜索基础教程哦, 我这里就不温故了. 那么有人要 ...

  4. logging 日志模块学习

    logging 日志模块,用于记录系统在运行过程中的一些关键信息,以便于对系统的运行状况进行跟踪,所以还是灰常重要滴,下面我就来从入门到放弃的系统学习一下日志既可以在屏幕上显示,又可以在文件中体现. ...

  5. 【腾讯Bugly干货分享】微信终端跨平台组件 mars 系列(一) - 高性能日志模块xlog

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57ff5932cde42f1f03de29b1 本文来源: 微信客户端开发团队 ...

  6. 日志模块logging使用心得

    在应用程序使用中,日志输出对应用维护人员.开发人员判断程序的问题起重要作用. 那么在python中如何定义程序的日志输出? 推荐使用日志模块logging 需求:实现日志内容输出在文件中和控制器中 i ...

  7. python日志模块

    许多应用程序中都会有日志模块,用于记录系统在运行过程中的一些关键信息,以便于对系 统的运行状况进行跟踪.在.NET平台中,有非常著名的第三方开源日志组件log4net,c++中,有人们熟悉的log4c ...

  8. ns3 Tutorial 中的日志模块(翻译)

      转载地址:http://blog.sina.com.cn/s/blog_8ecca79b0101d7fe.html     1  日志模块的使用   在运行 first.cc 脚本时,我们已经简单 ...

  9. logging日志模块

    为什么要做日志: 审计跟踪:但错误发生时,你需要清除知道该如何处理,通过对日志跟踪,你可以获取该错误发生的具体环境,你需要确切知道什么是什么引起该错误,什么对该错误不会造成影响. 跟踪应用的警告和错误 ...

随机推荐

  1. 使用webform、websevice来进行ajax请求操作

    通过使用webform(asp.net非mvc) .webservice 作为请求接口在前台发送ajax请求:1.前台代码: $.ajax({ type: "POST", //方法 ...

  2. 解决maven 引用JDK内部类编译错误 程序包:com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler不存在

    当maven项目里面有用到JDK内部的一些类或者接口的时候,用maven编译一般会出现如下错误: 程序包:com.sun.xml.internal.bind.marshaller.CharacterE ...

  3. jqGrid TreeGrid 加载数据 排序 扩展

    发现 jqGrid TreeGrid 加载的数据必须要排序 给了两种平滑数据模式尽然不内部递归 所以改了下源码加了个数据二次过滤器扩展 数据本该是这样的 结果没排序成这样了 (而且还得是从根节点到子节 ...

  4. Shell 语法报错记录

    sh: missing ] if 条件语句 “或”多个条件并行时 执行then命令 变量a等于aa且变量b等于bb 或者 变量c等于cc且变量d等于dd 这样的条件成立的话,输出success if ...

  5. spring 的自动定时任务

    spring的自动定时任务有两种 第一种:通过xml配置来设置 需要在xml中引入新的约束,并且需要配置<task:scheduled-tasks> ,主要配置内容如下: <?xml ...

  6. vulkan 的icb

    https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/chap30.html#device-generated-comma ...

  7. confluence配置搭建

    1.环境准备:需要安装jdk.需要mysql5.7数据库,创建数据库confluence并创建用户和密码 CREATE DATABASE `confluence` DEFAULT CHARACTER ...

  8. jvm crash分析

    问题描述:线上进程异常退出,查看服务器端日志,有jvm crash文件生成 # # A fatal error has been detected by the Java Runtime Enviro ...

  9. MULTIPOLYGON、POLYGON 封装为echart geoJson 数据封装

    一.环境.问题简述: 1.采用的事前后端分离,后端需要封装将点位获取的点位信息封装为geoJson数据类型,供前端利用echart 绘制地图: 2.思路:简单理解geoJson,将对应坐标点位封装为g ...

  10. Visual Studio 查看宏展开

    使用Visual Studio 开发c++项目,中遇到项目中宏定义套宏定义,难以阅读源代码的时候. 可在 项目-->右键-->配置属性-->c/c++ -->预处理器 --&g ...