Skip to content

Commit

Permalink
Forgot about logger class
Browse files Browse the repository at this point in the history
  • Loading branch information
Wisser Tg committed Aug 25, 2018
1 parent 3b586e0 commit e8421e3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .gitignore
@@ -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/*
47 changes: 47 additions & 0 deletions CommandLoggerLogger.cs
@@ -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;
}
}
}

0 comments on commit e8421e3

Please sign in to comment.