找回密码
 加入
搜索
查看: 2185|回复: 9

[AU3基础] 有没有写LOG日志的UDF

  [复制链接]
发表于 2018-9-12 16:53:19 | 显示全部楼层 |阅读模式
有没有写LOG日志的UDF?
发表于 2018-9-12 17:26:51 | 显示全部楼层
#include <EventLog.au3>
了解一下。
发表于 2018-9-12 23:24:40 | 显示全部楼层
win系統LOG? 自訂義LOG? 用於哪邊?
 楼主| 发表于 2018-9-13 09:06:10 | 显示全部楼层
自訂義LOG? 自定义软件的log生成。
 楼主| 发表于 2018-9-13 09:55:25 | 显示全部楼层
本帖最后由 redapple2008 于 2018-9-13 09:56 编辑

这个是加载dll写系统日志的,我自定议log文件需要自己写文件生成吗?

#include "_CustomEventLog.au3"

$MyEventName = "AutoIt"

$EventLog = _SetLog($MyEventName,"AutoIteventmsg.dll")

If NOT @error then 
    _RegisterEvent($EventLog, $SUCCESS, $App_Started, @ScriptName)
    _RegisterEvent($EventLog, $INFORMATION, $App_OK, "Just confirming this app is OK")
    _RegisterEvent($EventLog, $ERROR, $App_Error, "This app is not feeling very well" & @crlf & "Can someone call a doctor")
    _RegisterEvent($EventLog, $WARNING, $App_Warning, "There is no crap in this event log")
    _RegisterEvent($EventLog, $INFORMATION, $App_Information, "Nothing to see here")
    _RegisterEvent($EventLog, $INFORMATION, $App_Free, "This is my Free string" & @crlf & "with nothing at the begining")
    _RegisterEvent($EventLog, $SUCCESS, $App_Stopped, @ScriptName)
EndIf

;or using the normal AutoIt includes

$EventLog = _SetLog($MyEventName,"AutoIteventmsg.dll")

Global $aData[1]=[0]
$hEventLog = _EventLog__RegisterSource("",$EventLog)
_EventLog__Report($hEventLog, $INFORMATION, "None", $App_Information, "","Another message without the crap", $aData)
_EventLog__Close ($hEventLog)
发表于 2018-9-15 13:34:05 | 显示全部楼层
还有这个模块,我都是直接输出到文件。比如时间:事件
 楼主| 发表于 2018-9-18 08:53:44 | 显示全部楼层
hualong1009 发表于 2018-9-15 13:34
还有这个模块,我都是直接输出到文件。比如时间:事件

能不能举个例子?谢谢了!
发表于 2018-9-18 13:54:51 | 显示全部楼层
redapple2008 发表于 2018-9-18 08:53
能不能举个例子?谢谢了!

我不知道有这样的模块,自己写了个函数,输出
Func Send_Msg($Msg = "", $Level = 0)
        Global $MsgBox
        If $Level == 0 Then
                _GUICtrlListBox_InsertString($MsgBox, @YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg, 0)
                GUICtrlSetColor($MsgBox, 0x000000)
                FileWriteLine($ConfigDir&"\Test_Record.log" ,@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg)
        ElseIf $Level == 1 Then
                _GUICtrlListBox_InsertString($MsgBox, @YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg, 0)
                GUICtrlSetColor($MsgBox, 0x22B14C)
                FileWriteLine($ConfigDir&"\Test_Record.log" ,@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg)
        ElseIf $Level == 2 Then
                _GUICtrlListBox_InsertString($MsgBox, @YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg, 0)
                ;GUICtrlSetData($MsgBox, @YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg)
                GUICtrlSetColor($MsgBox, 0xED1C24)
                FileWriteLine($ConfigDir&"\Test_Record.log" ,@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg)
        ElseIf $Level == 3 Then
                FileWriteLine($ConfigDir&"\Test_Record.log" ,@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" -- "&$Msg)
        EndIf

EndFunc
 楼主| 发表于 2018-9-18 14:09:45 | 显示全部楼层
hualong1009 发表于 2018-9-18 13:54
我不知道有这样的模块,自己写了个函数,输出

谢谢了!十分感谢,有例子就好多了,我再研究研究。
发表于 2018-9-22 00:52:12 | 显示全部楼层
#include <EventLog.au3>
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 02:49 , Processed in 0.074736 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表