Peponi.Logger
1.0.2
dotnet add package Peponi.Logger --version 1.0.2
NuGet\Install-Package Peponi.Logger -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Peponi.Logger" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Peponi.Logger --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Peponi.Logger, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Peponi.Logger as a Cake Addin #addin nuget:?package=Peponi.Logger&version=1.0.2 // Install Peponi.Logger as a Cake Tool #tool nuget:?package=Peponi.Logger&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Peponi.Logger
1. Instruction
- This package is under MIT License.
- GitHub : Peponi
- Blog : Peponi
- Instruction & API information is on following section
1.1. About Peponi.Logger
Peponi.Logger is a package for logging.
Base concepts are:
1. Fast return
- Add log item and return immediately
2. High performance logger
- Has processor & writer per each logger
1.1.1. Peponi.Logger license
The MIT License (MIT)
Copyright (c) 2024 peponi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1.1.2. Peponi.Logger install
NuGet\Install-Package Peponi.Logger
2. Peponi.Logger
2.1. Quick start
using Peponi.Logger;
internal class Program
{
private static void Main(string[] args)
{
// Gets logger with default option
Log log = Log.GetLogger();
log.Write("Hello, World!");
}
}
using Peponi.Logger;
internal class Program
{
private static void Main(string[] args)
{
// Gets logger named "MyLog" with default option
Log log = Log.GetLogger("MyLog");
log.Write(LogType.Info, "Hello, World!");
}
}
2.2. Log
Members
Type Name Description LogOption Option Options for logging Methods
Return type Name Description Log GetLogger(string) Gets logger for given name Log GetLogger(LogOption?) Gets logger for given option void Write(string, DateTime?) Write log void Write(LogType, string, DateTime?) Write log LogType (Flags)
LogType Description General General Info Information Notify Notify Warning Warning Error Error Exception Exception Example
using Peponi.Logger; internal class Program { private static void Main(string[] args) { LogDirectoryOption directoryOption = new() { RootPath = $@"C:\Temp\Peponi.Log\", DirectoryTree = new() { LogDirectoryTree.None } }; LogFileOption fileOption = new() { LogFileSize = 20, FileCreatingRules = new() { LogFileCreatingRule.DateTime_Year, LogFileCreatingRule.DateTime_Month, LogFileCreatingRule.DateTime_Day, LogFileCreatingRule.Underbar, LogFileCreatingRule.LoggerName }, Extension = ".txt" }; LogMessageOption messageOption = new() { MessagePatterns = new() { LogMessagePattern.DateTime, LogMessagePattern.LoggerName, LogMessagePattern.LogType, LogMessagePattern.Message, LogMessagePattern.NewLine } }; LogOption option = new("MyLog", directoryOption, fileOption, messageOption); Log logger = Log.GetLogger(option); logger.Write(LogType.Info, "Logger created"); logger.Write(LogType.Error | LogType.Exception, "Logger Error & Exception"); } }
2.3. LogOption
Members
Type Name Description string LoggerName Logging base key name LogDirectoryOption DirectoryOption Configure directory tree LogFileOption FileOption Configure log file size and creating rule LogMessageOption MessageOption Configure log message format Description
- Configure logger options.
- Logger will work by given options.
- Concrete options are on following sections.
2.3.1. LogDirectoryOption
Members
Type Name Description string RootPath Root path of log List<LogDirectoryTree> DirectoryTree Configure directory tree Example
LogDirectoryOption directoryOption = new() { RootPath = $@"C:\Temp\Peponi.Log\", DirectoryTree = new() { LogDirectoryTree.DateTime_Year, LogDirectoryTree.DateTime_Month, LogDirectoryTree.DateTime_Day, LogDirectoryTree.LoggerName, } }; /* This option will create following folder tree: C |- Temp | |- Peponi.Log | | |- 2023 | | | |- 12 | | | | |- 26 | | | | | |- MyLog */
LogDirectoryTree
LogDirectoryTree Description None No additional folder LoggerName Given logger name DateTime_Second DateTime format ss
DateTime_Minute DateTime format mm
DateTime_Hour DateTime format HH
DateTime_Day DateTime format dd
DateTime_Month DateTime format MM
DateTime_Year DateTime format yy
2.3.2. LogFileOption
Members
Type Name Description uint LogFileSize - Unit : mb<br/>- Value :<br/>0 = Inf<br/>X = X mb<br/>- Default : 0 List<LogFileCreatingRule> FileCreatingRules Configure log file's creating rule string Extension Log file's extension<br/>Default : .log
Example
LogFileOption fileOption = new() { LogFileSize = 5, FileCreatingRules = new() { LogFileCreatingRule.DateTime_Year, LogFileCreatingRule.DateTime_Month, LogFileCreatingRule.DateTime_Day, LogFileCreatingRule.Underbar, LogFileCreatingRule.LoggerName }, Extension = ".txt" }; /* This option will create following log file : 20231226_MyLog.txt (5 mb) 20231226_MyLog_1.txt (5 mb) 20231226_MyLog_2.txt (2 mb) */
LogFileCreatingRule
LogFileCreatingRule Description LoggerName Given logger name DateTime_Second DateTime format ss
DateTime_Minute DateTime format mm
DateTime_Hour DateTime format HH
DateTime_Day DateTime format dd
DateTime_Month DateTime format MM
DateTime_Year DateTime format yyyy
Dot .
Space Underbar _
Dash -
2.3.3. LogMessageOption
Members
Type Name Description List<LogMessagePattern> MessagePatterns Configure log message Example
LogMessageOption messageOption = new() { MessagePatterns = new() { LogMessagePattern.DateTime, LogMessagePattern.LoggerName, LogMessagePattern.LogType, LogMessagePattern.Message, LogMessagePattern.NewLine } }; /* This option will create following log message : [2023-12-26 16.02.35.006] [MyLog] [General] Log message [2023-12-26 16.02.35.106] [MyLog] [General] Log message 2 */
LogMessagePattern
LogMessagePattern Description None No message LoggerName Given logger name<br/> [LoggerName]
DateTime [yyyy.MM.dd HH:mm:ss.fff]
LogType [LogType]
Message Message
NewLine Environment.NewLine
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Peponi.Core (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.0.2:
- Add package icon
Version 1.0.1:
- Fix comments error
Version 1.0.0:
- Initial upload