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控制台输出日志信息的截屏。

     

  • 相关阅读:
    ES6中的export,import ,export default
    centos7 安装php 多线程pthreads
    ubuntu系统安装nginx出现的错误(依赖环境没有安装完)
    ubuntu彻底干净卸载MySQL、Apache2、Php的方法(各版本通用
    mysql-ubuntu14.04彻底卸载mysql
    centos 中GTK的安装
    centos 安装cmake 3.3.2
    yum安装方式的php,切换NTS为ZTS版本
    eclipse中jad反编译工具的安装
    在SpringMVC中获取request对象的几种方式
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/4559178.html
Copyright © 2011-2022 走看看