<commit_before>﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;

namespace Tgstation.Server.Host.Watchdog
{
	/// <inheritdoc />
	sealed class Watchdog : IWatchdog
	{

		/// <summary>
		/// The <see cref="ILogger"/> for the <see cref="Watchdog"/>
		/// </summary>
		readonly ILogger<Watchdog> logger;

		/// <summary>
		/// Construct a <see cref="Watchdog"/>
		/// </summary>
		/// <param name="logger">The value of <see cref="logger"/></param>
		public Watchdog(ILogger<Watchdog> logger)
		{
			this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
		}

		/// <inheritdoc />
		public async Task RunAsync(string[] args, CancellationToken cancellationToken)
		{
			logger.LogInformation("Host watchdog starting...");

			string updateDirectory = null;
			try
			{
				var enviromentPath = Environment.GetEnvironmentVariable("PATH");
				var paths = enviromentPath.Split(';');
				var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

				var exeName = "dotnet";
				IEnumerable<string> enumerator;
				if (isWindows)
				{
					exeName += ".exe";
					enumerator = paths;
				}
				else
					enumerator = paths.Select(x => x.Split(':')).SelectMany(x => x);

				enumerator = enumerator.Select(x => Path.Combine(x, exeName));

				var dotnetPath = enumerator
								   .Where(x =>
								   {
									   logger.LogTrace("Checking for dotnet at {0}", x);
									   return File.Exists(x);
								   })<commit_msg>Debug log the host watchdog PID<commit_after>﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;

namespace Tgstation.Server.Host.Watchdog
{
	/// <inheritdoc />
	sealed class Watchdog : IWatchdog
	{

		/// <summary>
		/// The <see cref="ILogger"/> for the <see cref="Watchdog"/>
		/// </summary>
		readonly ILogger<Watchdog> logger;

		/// <summary>
		/// Construct a <see cref="Watchdog"/>
		/// </summary>
		/// <param name="logger">The value of <see cref="logger"/></param>
		public Watchdog(ILogger<Watchdog> logger)
		{
			this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
		}

		/// <inheritdoc />
		public async Task RunAsync(string[] args, CancellationToken cancellationToken)
		{
			logger.LogInformation("Host watchdog starting...");
			logger.LogDebug("PID: {0}", Process.GetCurrentProcess().Id);
			string updateDirectory = null;
			try
			{
				var enviromentPath = Environment.GetEnvironmentVariable("PATH");
				var paths = enviromentPath.Split(';');
				var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

				var exeName = "dotnet";
				IEnumerable<string> enumerator;
				if (isWindows)
				{
					exeName += ".exe";
					enumerator = paths;
				}
				else
					enumerator = paths.Select(x => x.Split(':')).SelectMany(x => x);

				enumerator = enumerator.Select(x => Path.Combine(x, exeName));

				var dotnetPath = enumerator
								   .Where(x =>
								   {
									   logger.LogTrace("Checking for dotnet at {0}", x);
									   return File.Exists(x);
								   })
{'fraction_non_alphanumeric': 0.14025974025974025, 'fraction_numerical': 0.0008658008658008658, 'mean_word_length': 3.310945273631841, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '7312356', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1049, 'n_words': 242}