zoukankan      html  css  js  c++  java
  • 如何写错误日志

    'BaseFunction

     

    '测试开关

    Public Enum TYPE_TestFlag

        OutExe = 0 '0-输出到DebugView --;

        OutTxt ='1-输出到日志文件--;

        OutBath = 2 '2-输出到DebugView 也输出到日志文件--;

        OutNull = 3 '3-无错误输出--;

    End Enum

     

    '测试开关常量

    Private Const m_TestFlag = TYPE_TestFlag.OutBath

     

     

    '写日志文件

    Public Sub WriteErrFile(ByVal strMsg As String)

        On Error GoTo ErrHandle

     

        Dim nFileID As Integer

        Dim strFileName As String

     

        strFileName = App.path + "\我的程序.dat"

        strMsg = "ErrTime:" + CStr(Now) + ";ErrDes:" + "我的程序->" + strMsg

     

        Select Case m_TestFlag

            Case TYPE_TestFlag.OutExe

                Call OutputDebugString(strMsg)

                Exit Sub

            Case TYPE_TestFlag.OutTxt

                nFileID = FreeFile

                Open strFileName For Append As #nFileID

                Write #nFileID, strMsg

                Close nFileID

                Exit Sub

            Case TYPE_TestFlag.OutBath

                Call OutputDebugString(strMsg)

                nFileID = FreeFile

                Open strFileName For Append As #nFileID

                Write #nFileID, strMsg

                Close nFileID

                Exit Sub

            Case TYPE_TestFlag.OutNull

                Exit Sub

            Case Else

                Exit Sub

        End Select

     

    ErrHandle:

        Err.Clear

        Resume Next

     

    End Sub

  • 相关阅读:
    WPF-触发器
    WPF使用socket实现简单聊天软件
    git常用命令备忘
    (转载)WPF中的动画——(一)基本概念
    WPF中的依赖项属性
    C#中的索引器
    C#中的装箱拆箱
    编程语言的弱类型、强类型、动态类型、静态类型
    WPF中的数据驱动
    WPF中的命令简介
  • 原文地址:https://www.cnblogs.com/no7dw/p/1612836.html
Copyright © 2011-2022 走看看