Files
Francis Hurteau 57c677da93 Copying //UE4/Dev-Enterprise@4705006 to Dev-Main (//UE4/Dev-Main)
#rb none
#lockdown Nick.Penwarden

[CL 4705151 by Francis Hurteau in Main branch]
2019-01-10 17:26:53 -05:00

72 lines
1.4 KiB
C#

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace nDisplayLauncher.Log
{
public class AppLogger : INotifyPropertyChanged
{
private AppLogger()
{
}
private static AppLogger _Instance;
public static AppLogger Instance
{
get
{
if (_Instance == null)
{
_Instance = new AppLogger();
}
return _Instance;
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnNotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
//Set property with OnNotifyPropertyChanged call
protected void Set<T>(ref T field, T newValue, string propertyName)
{
field = newValue;
OnNotifyPropertyChanged(propertyName);
}
private string _LogStr;
public string LogStr
{
get { return _LogStr; }
set { Set(ref _LogStr, value, "LogStr"); }
}
[MethodImpl(MethodImplOptions.Synchronized)]
public static void CleanLog()
{
Instance.LogStr = DateTime.Now.ToString() + System.Environment.NewLine;
}
[MethodImpl(MethodImplOptions.Synchronized)]
private static void Add(string text)
{
Instance.LogStr += DateTime.Now.ToString() + ": " + text + System.Environment.NewLine;
}
public static void Log(string text)
{
Add(text);
}
}
}