Merge pull request #13 from long237/Colins-Branch

Colins branch
This commit is contained in:
colincreasman 2021-12-13 20:23:55 -08:00 committed by GitHub
commit 4ecbb14940
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 177 additions and 122 deletions

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -10,7 +10,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
{
bool Log(LogEntry log);
IList<string> GetAllLogs();
// IList<string> GetAllLogs();
}
}

View File

@ -10,6 +10,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging.Contracts
{
ILogger CreateLogger()
{
return new DBLogger();
}
}
}

View File

@ -1,21 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;
// using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
public class ConsoleLogger : ILogger
{
public IList<string> GetAllLogs()
{
throw new NotImplementedException();
}
public bool Log(string description)
{
throw new NotImplementedException();
}
}
}
// namespace TeamHobby.HobbyProjectGenerator.Logging
// {
// public class ConsoleLogger : ILogger
// {
// public bool Log(LogEntry log)
// {
// return true;
// }
// }
// }

View File

@ -1,18 +1,23 @@
using System;
// using System;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
public class FileLogger : ILogger
{
public IList<string> GetAllLogs()
{
throw new NotImplementedException();
}
// namespace TeamHobby.HobbyProjectGenerator.Logging
// {
// public class FileLogger : Ilogger
// {
// public FileLogger()
// {
// }
public bool Log(string description)
{
throw new NotImplementedException();
}
}
// public IList<string> GetAllLogs()
// {
// throw new NotImplementedException();
// }
}
// public bool Log(LogEntry log)
// {
// throw new NotImplementedException();
// }
// }
// }

View File

@ -1,38 +1,58 @@
using System;
using System.Collections.Generic;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
// implementation of ILogger that stores logs as they initialize
public class InMemoryLogger : ILogger
{
// make readonly to prevent it from being changed somewhere other than in the constructor
private readonly IList<string> _logStore;
// using System;
// using System.Collections.Generic;
// namespace TeamHobby.HobbyProjectGenerator.Logging
// {
// // implementation of ILogger that stores logs as they initialize
// public class InMemoryLogger : ILogger
// {
// // make readonly to prevent it from being changed somewhere other than in the constructor
// private readonly IList<string> _logStore;
public InMemoryLogger()
{
// list of current logs
_logStore = new List<string>();
}
// public InMemoryLogger()
// {
// // list of current logs
// _logStore = new List<string>();
// }
// public InMemoryLogger(IList<string> logStore)
// {
// _logStore = logStore;
// }
// public bool Log(LogEntry entry)
// {
// if (entry is null)
// {
// throw new ArgumentNullException(nameof(entry));
// }
// try
// {
// // string interpolation to add UTC timestamp to log description
// //_logStore.Add($"{DateTime.UtcNow}-> {description}");
// return true;
// }
// catch
// {
// return false;
// }
// }
// public IList<string> GetAllLogs()
// {
// return _logStore;
// }
// public override bool Equals(object? obj)
// {
// return obj is InMemoryLogger logger &&
// EqualityComparer<IList<string>>.Default.Equals(_logStore, logger._logStore);
// }
public bool Log(string description)
{
try
{
// string interpolation to add UTC timestamp to log description
_logStore.Add($"{DateTime.UtcNow}-> {description}");
return true;
}
catch
{
return false;
}
}
public IList<string> GetAllLogs()
{
return _logStore;
}
}
// public override int GetHashCode()
// {
// return HashCode.Combine(_logStore);
// }
// }
}
// }

View File

@ -26,5 +26,29 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
public string description { get; init; }
public DateTime timestamp { get; init; }
// Constructor requireing only the description as an arg
// Assigns default values for LogLevel (Info), LogCategory (Server), user ("System"), and the UTC time at initialization for timestamp
public LogEntry(string description)
{
this.level = LogLevel.Info;
this.category = LogCategory.Server;
this.user = "System";
this.description = description;
this.timestamp = DateTime.UtcNow;
}
// Constructor with args for all fields except timestamp
// timestamp is always set to the UTC time at the time of initialization
public LogEntry(LogLevel level, string user, LogCategory category, string description)
{
this.level = level;
this.category = category;
this.user = user;
this.description = description;
this.timestamp = DateTime.UtcNow;
}
}
}

View File

@ -9,23 +9,23 @@ using TeamHobby.HobbyProjectGenerator.Logging.Implementations;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
internal class LoggingController
internal class LoggingManager
{
private readonly IDataSource<string> _conn;
private readonly ILogger _logger;
private readonly ILoggerFactory _factory;
// private readonly LogEntry _logEntry;
private readonly LogEntry _logEntry;
// Both Constructors take an IDataSource arg to make logging extensible to future data sources
// first constructor has no additional args - defaults to using the DBFactiry implementation
public LoggingController(IDataSource<string> dataSource)
public LoggingManager(IDataSource<string> dataSource)
{
_conn = dataSource;
_factory = new DBLoggerFactory();
_logger = _factory.CreateLogger();
}
// second constructor takes an additional ILoggerFactory arg - allows for extensible logger types
public LoggingController(IDataSource<string> dataSource, ILoggerFactory factory)
public LoggingManager(IDataSource<string> dataSource, ILoggerFactory factory)
{
_conn = dataSource;
_factory = factory;
@ -35,7 +35,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
public void Process()
{
_logger.Log();
_logger.Log(_logEntry);
}

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -25,91 +25,87 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|x86.ActiveCfg = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|x86.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|x86.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|x86.Build.0 = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|x86.ActiveCfg = Debug|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|x86.ActiveCfg = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|x86.Build.0 = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|x86.ActiveCfg = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|x86.Build.0 = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|x86.ActiveCfg = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|x86.Build.0 = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.ActiveCfg = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.Build.0 = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|x86.ActiveCfg = Debug|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|x86.Build.0 = Debug|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|x86.ActiveCfg = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|x86.Build.0 = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|x86.ActiveCfg = Debug|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|x86.ActiveCfg = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|x86.Build.0 = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|x86.ActiveCfg = Debug|x86
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|x86.Build.0 = Debug|x86
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.ActiveCfg = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.Build.0 = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|x86.ActiveCfg = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|x86.Build.0 = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|x86.ActiveCfg = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|x86.Build.0 = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|x86.ActiveCfg = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|x86.Build.0 = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.Build.0 = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.Build.0 = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|x86.ActiveCfg = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|x86.Build.0 = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|x86.ActiveCfg = Debug|x86
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|x86.Build.0 = Debug|x86
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.Build.0 = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.Build.0 = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.ActiveCfg = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.Build.0 = Release|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -7,8 +7,10 @@ using TeamHobby.HobbyProjectGenerator.UserManagement;
namespace TeamHobby.HobbyProjectGenerator.Main
{
public class GetCredentials
{
public string? GetUserName()
{
Console.WriteLine("Please enter a username:");
@ -24,6 +26,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
}
public class Controller
{
public static void Main(string[] args)
{
// Console customization
@ -42,8 +45,13 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//GetCredentials credentials = new GetCredentials();
//string? username = credentials.GetUserName();
//string? password = credentials.GetPassword();
// Console customization
// Change the look of the console
Console.Title = "HobbyProjectGenerator";
// Change console text color
Console.ForegroundColor = ConsoleColor.Green;
// Change terminal height
Console.WindowHeight = 40;
//Console.WriteLine(value: $"username is {username}\npassword is {password}");
// Creating the Factory class
@ -246,4 +254,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
}
}
}
}

View File

@ -5,7 +5,8 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>