-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
1722e27
commit 9c675f6
Showing
74 changed files
with
1,249 additions
and
3,985 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
configuration: Release | ||
platform: Any CPU | ||
version: BUILD {build} | ||
image: Visual Studio 2017 | ||
before_build: | ||
- cmd: nuget restore src/NLog.Targets.Syslog.sln -DisableParallelProcessing | ||
- ps: Set-AppveyorBuildVariable -Name NGP_VER -Value (& "$env:APPVEYOR_BUILD_FOLDER\tools\get-version.ps1" -versionInfoFile "$env:APPVEYOR_BUILD_FOLDER\src\NLog.Targets.Syslog\Properties\AssemblyInfo.cs") | ||
- ps: Update-AppveyorBuild -Version "$env:NGP_VER.$env:APPVEYOR_BUILD_NUMBER" | ||
- ps: (Get-Content "$env:APPVEYOR_BUILD_FOLDER\src\NLog.Targets.Syslog\Properties\AssemblyInfo.cs") -replace '(AssemblyFileVersion\(\")([\.0-9]+)(\"\)])',"`${1}$env:APPVEYOR_BUILD_VERSION`${3}" | Set-Content "$env:APPVEYOR_BUILD_FOLDER\src\NLog.Targets.Syslog\Properties\AssemblyInfo.cs" | ||
build: | ||
project: src/NLog.Targets.Syslog.sln | ||
verbosity: minimal | ||
- ps: | | ||
$mostRecentTag = git describe --abbrev=0 --tags | ||
$mostRecentVersion = $mostRecentTag.Substring(1) | ||
$currentCommitHash = git rev-parse --short HEAD | ||
Set-AppveyorBuildVariable -Name SW_VER -Value $mostRecentVersion | ||
Update-AppveyorBuild -Version "Build $env:APPVEYOR_BUILD_NUMBER - Commit $currentCommitHash - Tag v$env:SW_VER" | ||
build_script: | ||
- ps: | | ||
$additionalArgs = if ($env:APPVEYOR_REPO_TAG -ne 'true') { "-buildNumber=$env:APPVEYOR_BUILD_NUMBER" } | ||
.\tools\build.ps1 '-target=Pack' "-softwareVersion=$env:SW_VER" $additionalArgs | ||
after_build: | ||
- cmd: nuget pack src/NLog.Targets.Syslog/NLog.Targets.Syslog.csproj -Prop Configuration=Release -Prop Platform=AnyCPU | ||
- cmd: nuget pack src/NLog.Targets.Syslog/NLog.Targets.Syslog.Schema.nuspec -Prop version=%NGP_VER% | ||
artifacts: | ||
- path: NLog.Targets.Syslog*.nupkg | ||
- path: tools\artifacts\*.nupkg | ||
deploy: | ||
provider: NuGet | ||
api_key: | ||
secure: GcyRYCPxp53YxLHBjdeBRQeGimm4CJDDMnZFNQ1gb03PDAsR6Mp7PMWKzc7vjPKP | ||
skip_symbols: false | ||
on: | ||
appveyor_repo_tag: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks> | ||
<RootNamespace>FakeSyslogServer</RootNamespace> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
<OutputType>Library</OutputType> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
|
||
<Product>FakeSyslogServer</Product> | ||
<Copyright>Copyright © 2013 - present by Jesper Hess Nielsen, Luigi Berrettini and others: https://github.com/graffen/NLog.Targets.Syslog/graphs/contributors</Copyright> | ||
<AssemblyTitle>Fake Syslog target</AssemblyTitle> | ||
<AssemblyName>FakeSyslogServer</AssemblyName> | ||
<AssemblyVersion>0.0.0.0</AssemblyVersion> | ||
<FileVersion>0.1.0.0</FileVersion> | ||
<InformationalVersion>0.1.0-alpha-01-commitHash</InformationalVersion> | ||
<NeutralLanguage>en</NeutralLanguage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\NLog.Targets.Syslog\NLog.Targets.Syslog.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using NLog; | ||
using NLog.Common; | ||
|
||
namespace FakeSyslogServer | ||
{ | ||
public class TestAppHelper | ||
{ | ||
private static readonly Logger Logger; | ||
private static readonly string HugeMessage; | ||
|
||
private readonly Func<string, string> settings; | ||
private readonly Action<bool, SyslogServer> toggleSyslogServer; | ||
private readonly SyslogServer syslogServer; | ||
|
||
static TestAppHelper() | ||
{ | ||
var sb = new StringBuilder(65000); | ||
for (var i = 10; i <= 64000; i += 10) | ||
sb.Append(i.ToString("D10")); | ||
HugeMessage = sb.ToString(); | ||
|
||
//InternalLogger.LogLevel = LogLevel.Warn; | ||
//InternalLogger.LogToTrace = true; | ||
|
||
Logger = LogManager.GetCurrentClassLogger(); | ||
} | ||
|
||
public TestAppHelper(Func<string, string> settingProvider, Action<bool, SyslogServer> toggleSyslogServerFunc) | ||
{ | ||
TaskScheduler.UnobservedTaskException += HandleUnobservedTaskException; | ||
settings = settingProvider; | ||
toggleSyslogServer = toggleSyslogServerFunc; | ||
var tcpEndPoint = EndPoint("tcpIp", "tcpPort"); | ||
var udpEndPoint = EndPoint("udpIp", "udpPort"); | ||
syslogServer = new SyslogServer(udpEndPoint, tcpEndPoint); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
syslogServer.Dispose(); | ||
} | ||
|
||
private static void HandleUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) | ||
{ | ||
e.SetObserved(); | ||
foreach (var innerException in e.Exception.Flatten().InnerExceptions) | ||
{ | ||
Trace.WriteLine("******************** DANGEROUSLY UNOBSERVED TASK EXCEPTION!!!"); | ||
Trace.WriteLine(innerException); | ||
} | ||
} | ||
|
||
private IPEndPoint EndPoint(string ipKey, string portKey) | ||
{ | ||
var ip = IPAddress.Parse(settings(ipKey)); | ||
var port = int.Parse(settings(portKey)); | ||
return new IPEndPoint(ip, port); | ||
} | ||
|
||
public void PerformSelectedOperation(string operation) | ||
{ | ||
switch (operation) | ||
{ | ||
case "Trace": | ||
{ | ||
Logger.Trace("This is a sample trace message"); | ||
break; | ||
} | ||
case "Debug": | ||
{ | ||
Logger.Debug("This is a sample debug message"); | ||
break; | ||
} | ||
case "Info": | ||
{ | ||
Logger.Info("This is a sample info message"); | ||
break; | ||
} | ||
case "Warn": | ||
{ | ||
Logger.Warn("This is a sample warn message"); | ||
break; | ||
} | ||
case "Error": | ||
{ | ||
Logger.Error("This is a sample error message"); | ||
break; | ||
} | ||
case "Fatal": | ||
{ | ||
Logger.Fatal("This is a sample fatal message"); | ||
break; | ||
} | ||
case "FromFile": | ||
{ | ||
FromFile(); | ||
break; | ||
} | ||
case "Huge": | ||
{ | ||
Huge(); | ||
break; | ||
} | ||
case "Multiple": | ||
{ | ||
Multiple(); | ||
break; | ||
} | ||
case "Continuous": | ||
{ | ||
Continuous(); | ||
break; | ||
} | ||
case "Parallel": | ||
{ | ||
Parallel(); | ||
break; | ||
} | ||
case "StartSyslogServer": | ||
{ | ||
StartSyslogServer(); | ||
break; | ||
} | ||
case "StopSyslogServer": | ||
{ | ||
StopSyslogServer(); | ||
break; | ||
} | ||
default: | ||
{ | ||
throw new InvalidOperationException($"Operation '{operation}' is not supported"); | ||
} | ||
} | ||
} | ||
|
||
private void FromFile() | ||
{ | ||
var messagesFromFileLogLevel = settings("MessagesFromFileLogLevel"); | ||
var messagesFromFileFilePath = settings("MessagesFromFileFilePath"); | ||
var logLevel = messagesFromFileLogLevel == null ? LogLevel.Trace : LogLevel.FromString(messagesFromFileLogLevel); | ||
InternalLogger.Debug($"From file log level: {logLevel.Name}"); | ||
|
||
var fileNotFound = !File.Exists(messagesFromFileFilePath); | ||
if (fileNotFound) | ||
{ | ||
InternalLogger.Debug($"From file input file '{messagesFromFileFilePath}' does not exist"); | ||
return; | ||
} | ||
|
||
var messages = File.ReadAllLines(messagesFromFileFilePath).ToList(); | ||
messages.ForEach(m => Logger.Log(logLevel, m)); | ||
} | ||
|
||
private static void Huge() | ||
{ | ||
Task.Factory.StartNew(() => | ||
{ | ||
for (var i = 0; i < 101202; i++) | ||
{ | ||
Logger.Warn(HugeMessage); | ||
Thread.Sleep(10); | ||
} | ||
}); | ||
} | ||
|
||
private static void Multiple() | ||
{ | ||
const string paddedNumber = "D6"; | ||
System.Threading.Tasks.Parallel.For(1, 101, i => Logger.Log(LogLevel.Trace, i.ToString(paddedNumber))); | ||
System.Threading.Tasks.Parallel.For(101, 201, i => Logger.Log(LogLevel.Debug, i.ToString(paddedNumber))); | ||
System.Threading.Tasks.Parallel.For(201, 301, i => Logger.Log(LogLevel.Info, i.ToString(paddedNumber))); | ||
System.Threading.Tasks.Parallel.For(301, 401, i => Logger.Log(LogLevel.Warn, i.ToString(paddedNumber))); | ||
System.Threading.Tasks.Parallel.For(401, 501, i => Logger.Log(LogLevel.Error, i.ToString(paddedNumber))); | ||
System.Threading.Tasks.Parallel.For(501, 601, i => Logger.Log(LogLevel.Fatal, i.ToString(paddedNumber))); | ||
} | ||
|
||
private static void Continuous() | ||
{ | ||
Task.Factory.StartNew(() => | ||
{ | ||
for (var i = 0; i < 101202; i++) | ||
{ | ||
Logger.Warn(i); | ||
Thread.Sleep(10); | ||
} | ||
}); | ||
} | ||
|
||
private static void Parallel() | ||
{ | ||
Task.Factory.StartNew(() => | ||
{ | ||
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }; | ||
System.Threading.Tasks.Parallel.For(1, 404505, parallelOptions, i => Logger.Warn(i)); | ||
}); | ||
} | ||
|
||
private void StartSyslogServer() | ||
{ | ||
toggleSyslogServer(true, syslogServer); | ||
} | ||
|
||
private void StopSyslogServer() | ||
{ | ||
toggleSyslogServer(false, syslogServer); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.