Logging to Console or File
This commit is contained in:
parent
119c9edf43
commit
9d3b580a19
40
Logging/Logger.cs
Normal file
40
Logging/Logger.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Logging
|
||||||
|
{
|
||||||
|
public class Logger
|
||||||
|
{
|
||||||
|
private LogType logType;
|
||||||
|
private string logfilepath;
|
||||||
|
public Logger(LogType type)
|
||||||
|
{
|
||||||
|
this.logType = type;
|
||||||
|
this.logfilepath = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger(LogType type, string path)
|
||||||
|
{
|
||||||
|
this.logType = type;
|
||||||
|
this.logfilepath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(string message)
|
||||||
|
{
|
||||||
|
switch (this.logType)
|
||||||
|
{
|
||||||
|
case LogType.Console:
|
||||||
|
Console.WriteLine(message);
|
||||||
|
break;
|
||||||
|
case LogType.Logfile:
|
||||||
|
File.WriteAllText(this.logfilepath, message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LogType { Console, Logfile }
|
||||||
|
}
|
9
Logging/Logging.csproj
Normal file
9
Logging/Logging.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
23
Logging/bin/Debug/net6.0/Logging.deps.json
Normal file
23
Logging/bin/Debug/net6.0/Logging.deps.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"runtimeTarget": {
|
||||||
|
"name": ".NETCoreApp,Version=v6.0",
|
||||||
|
"signature": ""
|
||||||
|
},
|
||||||
|
"compilationOptions": {},
|
||||||
|
"targets": {
|
||||||
|
".NETCoreApp,Version=v6.0": {
|
||||||
|
"Logging/1.0.0": {
|
||||||
|
"runtime": {
|
||||||
|
"Logging.dll": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libraries": {
|
||||||
|
"Logging/1.0.0": {
|
||||||
|
"type": "project",
|
||||||
|
"serviceable": false,
|
||||||
|
"sha512": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
Logging/bin/Debug/net6.0/Logging.dll
Normal file
BIN
Logging/bin/Debug/net6.0/Logging.dll
Normal file
Binary file not shown.
BIN
Logging/bin/Debug/net6.0/Logging.pdb
Normal file
BIN
Logging/bin/Debug/net6.0/Logging.pdb
Normal file
Binary file not shown.
@ -0,0 +1,4 @@
|
|||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
|
23
Logging/obj/Debug/net6.0/Logging.AssemblyInfo.cs
Normal file
23
Logging/obj/Debug/net6.0/Logging.AssemblyInfo.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Dieser Code wurde von einem Tool generiert.
|
||||||
|
// Laufzeitversion:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||||
|
// der Code erneut generiert wird.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Logging")]
|
||||||
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyProductAttribute("Logging")]
|
||||||
|
[assembly: System.Reflection.AssemblyTitleAttribute("Logging")]
|
||||||
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
|
// Von der MSBuild WriteCodeFragment-Klasse generiert.
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
9571c7f7b3346058cb6bbbfaf736b35ba173e41f
|
@ -0,0 +1,10 @@
|
|||||||
|
is_global = true
|
||||||
|
build_property.TargetFramework = net6.0
|
||||||
|
build_property.TargetPlatformMinVersion =
|
||||||
|
build_property.UsingMicrosoftNETSdkWeb =
|
||||||
|
build_property.ProjectTypeGuids =
|
||||||
|
build_property.InvariantGlobalization =
|
||||||
|
build_property.PlatformNeutralAssembly =
|
||||||
|
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||||
|
build_property.RootNamespace = Logging
|
||||||
|
build_property.ProjectDir = D:\Documents\GitHub\astar\Logging\
|
8
Logging/obj/Debug/net6.0/Logging.GlobalUsings.g.cs
Normal file
8
Logging/obj/Debug/net6.0/Logging.GlobalUsings.g.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// <auto-generated/>
|
||||||
|
global using global::System;
|
||||||
|
global using global::System.Collections.Generic;
|
||||||
|
global using global::System.IO;
|
||||||
|
global using global::System.Linq;
|
||||||
|
global using global::System.Net.Http;
|
||||||
|
global using global::System.Threading;
|
||||||
|
global using global::System.Threading.Tasks;
|
BIN
Logging/obj/Debug/net6.0/Logging.assets.cache
Normal file
BIN
Logging/obj/Debug/net6.0/Logging.assets.cache
Normal file
Binary file not shown.
BIN
Logging/obj/Debug/net6.0/Logging.csproj.AssemblyReference.cache
Normal file
BIN
Logging/obj/Debug/net6.0/Logging.csproj.AssemblyReference.cache
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
ca186b20e9eea9da0579e3d2c6b09b668dcde22a
|
12
Logging/obj/Debug/net6.0/Logging.csproj.FileListAbsolute.txt
Normal file
12
Logging/obj/Debug/net6.0/Logging.csproj.FileListAbsolute.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
D:\Documents\GitHub\astar\Logging\bin\Debug\net6.0\Logging.deps.json
|
||||||
|
D:\Documents\GitHub\astar\Logging\bin\Debug\net6.0\Logging.dll
|
||||||
|
D:\Documents\GitHub\astar\Logging\bin\Debug\net6.0\Logging.pdb
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\Logging.csproj.AssemblyReference.cache
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\Logging.GeneratedMSBuildEditorConfig.editorconfig
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\Logging.AssemblyInfoInputs.cache
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\Logging.AssemblyInfo.cs
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\Logging.csproj.CoreCompileInputs.cache
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\Logging.dll
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\refint\Logging.dll
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\Logging.pdb
|
||||||
|
D:\Documents\GitHub\astar\Logging\obj\Debug\net6.0\ref\Logging.dll
|
BIN
Logging/obj/Debug/net6.0/Logging.dll
Normal file
BIN
Logging/obj/Debug/net6.0/Logging.dll
Normal file
Binary file not shown.
BIN
Logging/obj/Debug/net6.0/Logging.pdb
Normal file
BIN
Logging/obj/Debug/net6.0/Logging.pdb
Normal file
Binary file not shown.
BIN
Logging/obj/Debug/net6.0/ref/Logging.dll
Normal file
BIN
Logging/obj/Debug/net6.0/ref/Logging.dll
Normal file
Binary file not shown.
BIN
Logging/obj/Debug/net6.0/refint/Logging.dll
Normal file
BIN
Logging/obj/Debug/net6.0/refint/Logging.dll
Normal file
Binary file not shown.
62
Logging/obj/Logging.csproj.nuget.dgspec.json
Normal file
62
Logging/obj/Logging.csproj.nuget.dgspec.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"format": 1,
|
||||||
|
"restore": {
|
||||||
|
"D:\\Documents\\GitHub\\astar\\Logging\\Logging.csproj": {}
|
||||||
|
},
|
||||||
|
"projects": {
|
||||||
|
"D:\\Documents\\GitHub\\astar\\Logging\\Logging.csproj": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "D:\\Documents\\GitHub\\astar\\Logging\\Logging.csproj",
|
||||||
|
"projectName": "Logging",
|
||||||
|
"projectPath": "D:\\Documents\\GitHub\\astar\\Logging\\Logging.csproj",
|
||||||
|
"packagesPath": "C:\\Users\\glax\\.nuget\\packages\\",
|
||||||
|
"outputPath": "D:\\Documents\\GitHub\\astar\\Logging\\obj\\",
|
||||||
|
"projectStyle": "PackageReference",
|
||||||
|
"configFilePaths": [
|
||||||
|
"C:\\Users\\glax\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||||
|
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||||
|
],
|
||||||
|
"originalTargetFrameworks": [
|
||||||
|
"net6.0"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"projectReferences": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"warningProperties": {
|
||||||
|
"warnAsError": [
|
||||||
|
"NU1605"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"imports": [
|
||||||
|
"net461",
|
||||||
|
"net462",
|
||||||
|
"net47",
|
||||||
|
"net471",
|
||||||
|
"net472",
|
||||||
|
"net48"
|
||||||
|
],
|
||||||
|
"assetTargetFallback": true,
|
||||||
|
"warn": true,
|
||||||
|
"frameworkReferences": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"privateAssets": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.202\\RuntimeIdentifierGraph.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Logging/obj/Logging.csproj.nuget.g.props
Normal file
15
Logging/obj/Logging.csproj.nuget.g.props
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||||
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||||
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\glax\.nuget\packages\</NuGetPackageFolders>
|
||||||
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.1.0</NuGetToolVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<SourceRoot Include="C:\Users\glax\.nuget\packages\" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
2
Logging/obj/Logging.csproj.nuget.g.targets
Normal file
2
Logging/obj/Logging.csproj.nuget.g.targets
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
@ -0,0 +1,4 @@
|
|||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
|
23
Logging/obj/Release/net6.0/Logging.AssemblyInfo.cs
Normal file
23
Logging/obj/Release/net6.0/Logging.AssemblyInfo.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Dieser Code wurde von einem Tool generiert.
|
||||||
|
// Laufzeitversion:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||||
|
// der Code erneut generiert wird.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Logging")]
|
||||||
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||||
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyProductAttribute("Logging")]
|
||||||
|
[assembly: System.Reflection.AssemblyTitleAttribute("Logging")]
|
||||||
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
|
// Von der MSBuild WriteCodeFragment-Klasse generiert.
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
7a5c8249b1904df4522dbda5c0a0ef884f23e36e
|
@ -0,0 +1,10 @@
|
|||||||
|
is_global = true
|
||||||
|
build_property.TargetFramework = net6.0
|
||||||
|
build_property.TargetPlatformMinVersion =
|
||||||
|
build_property.UsingMicrosoftNETSdkWeb =
|
||||||
|
build_property.ProjectTypeGuids =
|
||||||
|
build_property.InvariantGlobalization =
|
||||||
|
build_property.PlatformNeutralAssembly =
|
||||||
|
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||||
|
build_property.RootNamespace = Logging
|
||||||
|
build_property.ProjectDir = D:\Documents\GitHub\astar\Logging\
|
8
Logging/obj/Release/net6.0/Logging.GlobalUsings.g.cs
Normal file
8
Logging/obj/Release/net6.0/Logging.GlobalUsings.g.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// <auto-generated/>
|
||||||
|
global using global::System;
|
||||||
|
global using global::System.Collections.Generic;
|
||||||
|
global using global::System.IO;
|
||||||
|
global using global::System.Linq;
|
||||||
|
global using global::System.Net.Http;
|
||||||
|
global using global::System.Threading;
|
||||||
|
global using global::System.Threading.Tasks;
|
BIN
Logging/obj/Release/net6.0/Logging.assets.cache
Normal file
BIN
Logging/obj/Release/net6.0/Logging.assets.cache
Normal file
Binary file not shown.
Binary file not shown.
67
Logging/obj/project.assets.json
Normal file
67
Logging/obj/project.assets.json
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"targets": {
|
||||||
|
"net6.0": {}
|
||||||
|
},
|
||||||
|
"libraries": {},
|
||||||
|
"projectFileDependencyGroups": {
|
||||||
|
"net6.0": []
|
||||||
|
},
|
||||||
|
"packageFolders": {
|
||||||
|
"C:\\Users\\glax\\.nuget\\packages\\": {}
|
||||||
|
},
|
||||||
|
"project": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "D:\\Documents\\GitHub\\astar\\Logging\\Logging.csproj",
|
||||||
|
"projectName": "Logging",
|
||||||
|
"projectPath": "D:\\Documents\\GitHub\\astar\\Logging\\Logging.csproj",
|
||||||
|
"packagesPath": "C:\\Users\\glax\\.nuget\\packages\\",
|
||||||
|
"outputPath": "D:\\Documents\\GitHub\\astar\\Logging\\obj\\",
|
||||||
|
"projectStyle": "PackageReference",
|
||||||
|
"configFilePaths": [
|
||||||
|
"C:\\Users\\glax\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||||
|
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||||
|
],
|
||||||
|
"originalTargetFrameworks": [
|
||||||
|
"net6.0"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"projectReferences": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"warningProperties": {
|
||||||
|
"warnAsError": [
|
||||||
|
"NU1605"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"imports": [
|
||||||
|
"net461",
|
||||||
|
"net462",
|
||||||
|
"net47",
|
||||||
|
"net471",
|
||||||
|
"net472",
|
||||||
|
"net48"
|
||||||
|
],
|
||||||
|
"assetTargetFallback": true,
|
||||||
|
"warn": true,
|
||||||
|
"frameworkReferences": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"privateAssets": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.202\\RuntimeIdentifierGraph.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
Logging/obj/project.nuget.cache
Normal file
8
Logging/obj/project.nuget.cache
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"dgSpecHash": "Bzeus1xpcjAcNWDy36kGNhprv48erGRpIqHoE/JJcwEjtHdQo4AJeMidy4DLd/gjVjMusBQkfWxQ4lF0iNKdjw==",
|
||||||
|
"success": true,
|
||||||
|
"projectFilePath": "D:\\Documents\\GitHub\\astar\\Logging\\Logging.csproj",
|
||||||
|
"expectedPackageFiles": [],
|
||||||
|
"logs": []
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user