An attempt to add logger class
This commit is contained in:
parent
9cffd0ff35
commit
e7e1813d53
@ -33,7 +33,7 @@
|
|||||||
<SuiteName>ISEN-Repair</SuiteName>
|
<SuiteName>ISEN-Repair</SuiteName>
|
||||||
<MinimumRequiredVersion>0.8.1.0</MinimumRequiredVersion>
|
<MinimumRequiredVersion>0.8.1.0</MinimumRequiredVersion>
|
||||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||||
<WebPage>publish.htm</WebPage>
|
<WebPage>index.htm</WebPage>
|
||||||
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
|
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
|
||||||
<ApplicationRevision>2</ApplicationRevision>
|
<ApplicationRevision>2</ApplicationRevision>
|
||||||
<ApplicationVersion>0.9.5.%2a</ApplicationVersion>
|
<ApplicationVersion>0.9.5.%2a</ApplicationVersion>
|
||||||
@ -171,6 +171,7 @@
|
|||||||
<Compile Include="IDGenerator.vb">
|
<Compile Include="IDGenerator.vb">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Logger.vb" />
|
||||||
<Compile Include="Main.vb">
|
<Compile Include="Main.vb">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
42
ISEN-Repair Inventory Manager/Logger.vb
Normal file
42
ISEN-Repair Inventory Manager/Logger.vb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
Imports System.IO
|
||||||
|
|
||||||
|
Public Class Logger
|
||||||
|
'DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||||
|
|
||||||
|
Dim logFileName As String = "logs\" & DateTime.Now.ToString("yyyy-MM-dd") & ".txt"
|
||||||
|
|
||||||
|
Shared Sub Load()
|
||||||
|
If Not My.Computer.FileSystem.DirectoryExists("logs") Then My.Computer.FileSystem.CreateDirectory("logs")
|
||||||
|
If Not My.Computer.FileSystem.FileExists(logFileName) Then File.WriteAllLines(logFileName, {"LOG FILE - " & DateTime.Now.ToString("dd/MM/yyyy"), "--------------------", "[INFO] Loading software"})
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Info(str As String)
|
||||||
|
Dim objWriter As New StreamWriter(logFileName, True)
|
||||||
|
Try
|
||||||
|
objWriter.WriteLineAsync("[INFO] " & str)
|
||||||
|
Catch ex As Exception
|
||||||
|
MsgBox(ex.ToString)
|
||||||
|
End Try
|
||||||
|
objWriter.Close()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Warn(str As String)
|
||||||
|
Dim objWriter As New StreamWriter(logFileName, True)
|
||||||
|
Try
|
||||||
|
objWriter.WriteLineAsync("[WARN] " & str)
|
||||||
|
Catch ex As Exception
|
||||||
|
MsgBox(ex.ToString)
|
||||||
|
End Try
|
||||||
|
objWriter.Close()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Critical(str As String)
|
||||||
|
Dim objWriter As New StreamWriter(logFileName, True)
|
||||||
|
Try
|
||||||
|
objWriter.WriteLineAsync("[CRITICAL] " & str)
|
||||||
|
Catch ex As Exception
|
||||||
|
MsgBox(ex.ToString)
|
||||||
|
End Try
|
||||||
|
objWriter.Close()
|
||||||
|
End Sub
|
||||||
|
End Class
|
@ -6,6 +6,7 @@ Public Class Main
|
|||||||
Dim idList As New ArrayList
|
Dim idList As New ArrayList
|
||||||
|
|
||||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
|
Logger.Load()
|
||||||
CheckIfFirstRun()
|
CheckIfFirstRun()
|
||||||
ListAllInv()
|
ListAllInv()
|
||||||
End Sub
|
End Sub
|
||||||
|
Reference in New Issue
Block a user