Added Splunk Logging and GrayLog Logging
This commit is contained in:
79
EonaCat.Logger/Splunk/SplunkServer.cs
Normal file
79
EonaCat.Logger/Splunk/SplunkServer.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
|
||||
namespace EonaCat.Logger.SplunkServer
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
|
||||
/// <summary>
|
||||
/// Splunk Server.
|
||||
/// </summary>
|
||||
public class SplunkServer
|
||||
{
|
||||
/// <summary>
|
||||
/// SplunkHecUrl
|
||||
/// </summary>
|
||||
public string SplunkHecUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _splunkHecUrl;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_splunkHecUrl) && !_splunkHecUrl.ToLower().Contains("http"))
|
||||
{
|
||||
value = $"http://{value}";
|
||||
}
|
||||
_splunkHecUrl = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHttpsHecUrl => HasHecUrl && _splunkHecUrl.ToLower().StartsWith("https");
|
||||
|
||||
/// <summary>
|
||||
/// SplunkHecToken
|
||||
/// </summary>
|
||||
public string SplunkHecToken
|
||||
{
|
||||
get
|
||||
{
|
||||
return _splunkHecToken;
|
||||
}
|
||||
set
|
||||
{
|
||||
_splunkHecToken = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal readonly object SendLock = new object();
|
||||
private string _splunkHecUrl = "https://127.0.0.1:8088";
|
||||
private string _splunkHecToken = "splunk-hec-token";
|
||||
private string _hostName;
|
||||
|
||||
public bool HasHecToken => !string.IsNullOrWhiteSpace(SplunkHecToken) && SplunkHecToken != "splunk-hec-token";
|
||||
|
||||
public bool HasHecUrl => !string.IsNullOrWhiteSpace(SplunkHecUrl);
|
||||
|
||||
public bool IsLocalHost => HasHecUrl && (SplunkHecUrl.ToLower().Contains("127.0.0.1") || SplunkHecUrl.ToLower().Contains("localhost"));
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate the object.
|
||||
/// </summary>
|
||||
public SplunkServer()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate the object.
|
||||
/// </summary>
|
||||
/// <param name="splunkHecUrl">splunkHecUrl.</param>
|
||||
/// <param name="splunkHecToken">splunkHecToken.</param>
|
||||
public SplunkServer(string splunkHecUrl, string splunkHecToken)
|
||||
{
|
||||
SplunkHecUrl = splunkHecUrl;
|
||||
SplunkHecToken = splunkHecToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user