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
Wisser Tg
committed
Aug 25, 2018
1 parent
3b586e0
commit e8421e3
Showing
2 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
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,7 +1,7 @@ | ||
# We're disabling useless for github folders | ||
bin/[Rr]elease/ | ||
bin/[Dd]ebug/ | ||
obj/ | ||
lib/ | ||
bin/[Rr]elease/* | ||
bin/[Dd]ebug/* | ||
obj/* | ||
lib/* | ||
# Also visual studio folder | ||
.vs | ||
.vs/* |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.IO; | ||
|
||
namespace coolpuppy24.commandlogger | ||
{ | ||
/// <summary> | ||
/// Using this like an adapter for StreamWriter. | ||
/// </summary> | ||
public sealed class CommandLoggerLogger | ||
{ | ||
private string m_filepath; | ||
private FileMode m_filemode; | ||
private FileAccess m_fileaccess; | ||
public CommandLoggerLogger() | ||
{ | ||
this.m_filepath = CommandLoggerCore.Instance.Directory + @"\Log.txt"; | ||
|
||
this.m_filemode = FileMode.Append; | ||
this.m_fileaccess = FileAccess.Write; | ||
} | ||
public CommandLoggerLogger(string FilePath) : this() | ||
{ | ||
this.m_filepath = CommandLoggerCore.Instance.Directory + FilePath; | ||
|
||
this.m_filemode = FileMode.Append; | ||
this.m_fileaccess = FileAccess.Write; | ||
} | ||
|
||
public void Log(string Message) | ||
{ | ||
if (!File.Exists(this.m_filepath)) | ||
this.m_filemode = FileMode.CreateNew; | ||
using (StreamWriter sw = new StreamWriter(new FileStream(this.m_filepath, this.m_filemode, this.m_fileaccess))) | ||
sw.WriteLine(Message); | ||
if (this.m_filemode == FileMode.CreateNew) | ||
this.m_filemode = FileMode.Append; | ||
} | ||
public void LogWarning(string Message) | ||
{ | ||
if (!File.Exists(this.m_filepath)) | ||
this.m_filemode = FileMode.CreateNew; | ||
using (StreamWriter sw = new StreamWriter(new FileStream(this.m_filepath, this.m_filemode, this.m_fileaccess))) | ||
sw.WriteLine(Message); | ||
if (this.m_filemode == FileMode.CreateNew) | ||
this.m_filemode = FileMode.Append; | ||
} | ||
} | ||
} |