mirror of
https://github.com/Tribufu/TribufuDotNet
synced 2026-08-18 17:11:08 +00:00
Migrate to new tribufu project structure (#2)
* Migrate to new tribufu project structure * Update .gitignore * Remove old api files * Update Directory.Build.props * Rename solution
This commit is contained in:
parent
be25ee8fe3
commit
7e8e192dc3
115 changed files with 41 additions and 262 deletions
20
Source/Tribufu.Logging/LogLevel.cs
Normal file
20
Source/Tribufu.Logging/LogLevel.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
namespace Tribufu.Logging
|
||||
{
|
||||
public enum LogLevel : byte
|
||||
{
|
||||
Off = 0,
|
||||
|
||||
Error = 1,
|
||||
|
||||
Warn = 2,
|
||||
|
||||
Info = 3,
|
||||
|
||||
Debug = 4,
|
||||
|
||||
Trace = 5,
|
||||
}
|
||||
}
|
||||
79
Source/Tribufu.Logging/Logger.cs
Normal file
79
Source/Tribufu.Logging/Logger.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
using System;
|
||||
|
||||
namespace Tribufu.Logging
|
||||
{
|
||||
public static class Logger
|
||||
{
|
||||
private static LogLevel _level = LogLevel.Off;
|
||||
|
||||
public static void Initialize(LogLevel level = LogLevel.Off)
|
||||
{
|
||||
_level = level;
|
||||
}
|
||||
|
||||
public static void Info(object context, string message)
|
||||
{
|
||||
Info($"({context.GetType().Name}) {message}");
|
||||
}
|
||||
|
||||
public static void Warn(object context, string message)
|
||||
{
|
||||
Warn($"({context.GetType().Name}) {message}");
|
||||
}
|
||||
|
||||
public static void Error(object context, string message)
|
||||
{
|
||||
Error($"({context.GetType().Name}) {message}");
|
||||
}
|
||||
|
||||
public static void Debug(object context, string message)
|
||||
{
|
||||
Debug($"({context.GetType().Name}) {message}");
|
||||
}
|
||||
|
||||
public static void Trace(object context, string message)
|
||||
{
|
||||
Trace($"({context.GetType().Name}) {message}");
|
||||
}
|
||||
|
||||
public static void Info(string message)
|
||||
{
|
||||
Log(LogLevel.Info, message, ConsoleColor.Green);
|
||||
}
|
||||
|
||||
public static void Warn(string message)
|
||||
{
|
||||
Log(LogLevel.Warn, message, ConsoleColor.Yellow);
|
||||
}
|
||||
|
||||
public static void Error(string message)
|
||||
{
|
||||
Log(LogLevel.Error, message, ConsoleColor.Red);
|
||||
}
|
||||
|
||||
public static void Debug(string message)
|
||||
{
|
||||
Log(LogLevel.Debug, message, ConsoleColor.White);
|
||||
}
|
||||
|
||||
public static void Trace(string message)
|
||||
{
|
||||
Log(LogLevel.Trace, message, ConsoleColor.DarkGray);
|
||||
}
|
||||
|
||||
private static void Log(LogLevel level, string message, ConsoleColor color)
|
||||
{
|
||||
if (level <= _level)
|
||||
{
|
||||
var defaultColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = color;
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
|
||||
Console.WriteLine($"[{timestamp}] [{level.ToString().ToUpper()}]: {message}");
|
||||
Console.ForegroundColor = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Source/Tribufu.Logging/README.md
Normal file
1
Source/Tribufu.Logging/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Tribufu Logging
|
||||
19
Source/Tribufu.Logging/Tribufu.Logging.csproj
Normal file
19
Source/Tribufu.Logging/Tribufu.Logging.csproj
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<PackageId>Tribufu.Logging</PackageId>
|
||||
<Description>Tribufu Logging</Description>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IsPublishable>false</IsPublishable>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue