-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60122eb
commit bef32dc
Showing
4 changed files
with
26 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
set pwd=%cd% | ||
cd .\test | ||
main.vbs | ||
more test.log | ||
cd %pwd% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
Option Explicit | ||
|
||
Private Const LogName = "test.log" ' where to write | ||
|
||
'test | ||
Private Sub test() | ||
writeLog("write a log") | ||
End Sub | ||
Private Const logFileName = "test.log" ' where to write | ||
Private Const forAppending = 8 ' open files for append | ||
|
||
Public Function writeLog(logMsg): | ||
Dim localTime, NewLog, logFile | ||
localTime = "[" & Now() & "]" | ||
NewLog = localTime & " " & logMsg | ||
Dim localTime, logFile | ||
localTime = "[" & Now() & "]:" | ||
logMsg = localTime & " " & logMsg | ||
Set logFile = openLogFile() | ||
logFile.WriteLine(NewLog) | ||
logFile.WriteLine(logMsg) | ||
Set logFile = Nothing | ||
End Function | ||
|
||
Private Function openLogFile() | ||
Dim fso | ||
Set fso = CreateObject("Scripting.FileSystemObject") | ||
If fso.FileExists(LogName) Then | ||
Set openLogFile = fso.OpenTextFile(LogName, 8, false) | ||
If fso.FileExists(logFileName) Then | ||
Set openLogFile = fso.OpenTextFile(logFileName, forAppending, false) | ||
Else | ||
fso.CreateTextFile(LogName) | ||
Set openLogFile = fso.OpenTextFile(LogName, 8, false) | ||
fso.CreateTextFile(logFileName) | ||
Set openLogFile = fso.OpenTextFile(logFileName, forAppending, false) | ||
End If | ||
Set fso = Nothing | ||
End Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters