<commit_before>#TODO: Add params for TCP
#TODO: Add params for USP
#TODO: Add params for HTTP




function ToSerilogSplunkViaTcp{
   [CmdletBinding(DefaultParameterSetName = 'FromPipeline')]
   param(
     [Parameter(ValueFromPipeline = $true, ParameterSetName = 'FromPipeline')]
     [object] $InputObject,
     [Parameter(Mandatory = $true)]
     [string] $splunkHost,
     [Parameter(Mandatory = $true)]
     [int] $port
   )
 
   begin
   {  
      
      Write-Verbose "Playing Around with PowerShell and Serilog to ToSerilogSplunk"

      function LoadSerilog{
        $path = "C:\Code\serilog-powershell\lib\Serilog.dll"
        $fullpath = "C:\Code\serilog-powershell\lib\Serilog.FullNetFx.dll"

        [System.Reflection.Assembly]::LoadFile($path)
        [System.Reflection.Assembly]::LoadFile($fullpath)

        [System.Reflection.Assembly]::LoadFile("C:\Code\serilog-powershell\lib\Splunk.Logging.Common.dll")
        [System.Reflection.Assembly]::LoadFile("C:\Code\serilog-powershell\lib\Splunk.Client.dll")
        [System.Reflection.Assembly]::LoadFile("C:\Code\serilog-powershell\lib\Serilog.Sinks.Splunk.FullNetFx.dll")

        $config = New-Object -TypeName "Serilog.LoggerConfiguration"
        
        [Serilog.LoggerConfigurationSplunkExtensions]::SplunkViaTcp($config.WriteTo, $splunkHost ,$port, [Serilog.Events.LogEventLevel]::Verbose, $null)
#"127.0.0.1", 10001)
        $log = $config.CreateLogger()
        [Serilog.Log]::Logger = $log

        return $log
      }

      function Cleanup {
        $oldLog = [Serilog.Log]::Logger 
        $oldLog.Dispose()
      } 

     $log = LoadSerilog
  
   }
 
  process{
        [Serilog.Log]::Information("{0}", $InputObject)
  }
  end { 
    Cleanup 
  } 
}



function ToSerilogSplunk{
   [CmdletBinding(DefaultParameterSetName = 'FromPipeline')]<commit_msg>log level<commit_after>#TODO: Add params for TCP
#TODO: Add params for UDP
#TODO: Add params for HTTP

#TODO: Choco package to get NuGet dependencies

function ToSplunkViaTcp{
   [CmdletBinding(DefaultParameterSetName = 'FromPipeline')]
   param(
     [Parameter(ValueFromPipeline = $true, ParameterSetName = 'FromPipeline')]
     [object] $InputObject,
     [Parameter(Mandatory = $true)]
     [string] $splunkHost,
     [Parameter(Mandatory = $true)]
     [int] $port,
     [Serilog.Events.LogEventLevel] $level = [Serilog.Events.LogEventLevel]::Information
   )
 
   begin
   {  
      
      Write-Verbose "Playing Around with PowerShell and Serilog to ToSplunkViaTcp"

      function LoadSerilog{

        $path = "C:\Code\serilog-powershell\lib\Serilog.dll"
        $fullpath = "C:\Code\serilog-powershell\lib\Serilog.FullNetFx.dll"

        [System.Reflection.Assembly]::LoadFile($path)
        [System.Reflection.Assembly]::LoadFile($fullpath)

        [System.Reflection.Assembly]::LoadFile("C:\Code\serilog-powershell\lib\Splunk.Logging.Common.dll")
        [System.Reflection.Assembly]::LoadFile("C:\Code\serilog-powershell\lib\Splunk.Client.dll")
        [System.Reflection.Assembly]::LoadFile("C:\Code\serilog-powershell\lib\Serilog.Sinks.Splunk.FullNetFx.dll")

        $config = New-Object -TypeName "Serilog.LoggerConfiguration"
        
        [Serilog.LoggerConfigurationSplunkExtensions]::SplunkViaTcp($config.WriteTo, $splunkHost ,$port, $level, $null)
        $log = $config.CreateLogger()
        [Serilog.Log]::Logger = $log

        return $log
      }

      function Cleanup {
        $oldLog = [Serilog.Log]::Logger 
        $oldLog.Dispose()
      } 

     $log = LoadSerilog
  
   }
 
  process{

        #TODO: Switch??

        [Serilog.Log]::Information("{0}", $InputObject)
  }
  end { 
    Cleanup 
  } 
}



function ToSerilogSplunk{
   [CmdletBinding(DefaultParameterSetName = 'FromPipeline')]
{'fraction_non_alphanumeric': 0.1339001062699256, 'fraction_numerical': 0.0034537725823591925, 'mean_word_length': 3.2020089285714284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4278816', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1262, 'n_words': 186}