zoukankan      html  css  js  c++  java
  • WorldWind源码剖析系列:日志类Log

    Utility工程中的日志类Log主要用来输出Debug状态下的调试信息。该类的类图如下:

     

    日志类Log中使用到的类和内嵌结构体类型主要有以下这些:

    public class LogEventArgs : EventArgs//日志事件参数

    {

            public int level;

            public string category;

            public string message;

            public LogEventArgs(int _l, string _c, string _m)

            {

                level = _l;

                category = _c;

                message = _m;

            }

     }

            public struct Levels//调试日志等级

            {

                public static readonly int Error = 0;

                public static readonly int Warning = 2;

                public static readonly int Debug = 5;

                public static readonly int Verbose = 7;

            };

    日志类Log中主要的字段、属性和方法有:

           static StreamWriter logWriter;//日志写盘的流式写入器

           static string logPath;//日志路径,默认为“C:Documents and SettingsAdministratorApplication DataNASAWorld Wind1.4.0.0”

           static string logFilePath;//日志文件路径,为logPath+ “WorldWind.log”

    public static int Level;//调试日志等级

    其中的方法都很简单,不再详细赘述。只简单的说明其中三个常用的日志写出函数:

    public static void Write( Exception caught )静态函数在程序中任何不活异常的地方被调用,用来将异常信息以“年月日时分秒.txt”为名称输出到文本文件中,默认的异常日志输出路径为“C:Documents and SettingsAdministratorApplication DataNASAWorld Wind1.4.0.0”。

    public static void DebugWrite( Exception caught ) 静态函数与public static void Write( Exception caught )静态函数功能一样,只不过是党程序处于Debug状态时才写出异常信息。

    public static void Write(int level, string category, string message) 静态函数只将日志等级<= Log.Level(4或6)的日志写入到WorldWind.log文件中去。

    下图是日志类Log在调试状态下向Output控制台输出日志信息的截屏。

     

  • 相关阅读:
    'jar' 不是内部或外部命令,也不是可运行的程序 或批处理文件。或批处理文件
    idea 集成 javap
    JVM_ 动态链接
    远程服务调用RMI框架 演示,和底层原理解析
    IO/NIO/AIO 解读
    JUC 并发编程--10, 阻塞队列之--LinkedBlockingDeque 工作窃取, 代码演示
    github,使用技巧, 让你的开发事半功倍
    JVM-相关,这里引用别人博客
    python开发学习day01 (编程; 计算机三大核心硬件 ; 操作系统与平台)
    webdriervAPI(多表单切换)
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/4559178.html
Copyright © 2011-2022 走看看