<commit_before>using System;
using Serilog;

namespace Thinktecture.Relay.OnPremiseConnector.SignalR
{
	internal class AutomaticDisconnectChecker: IAutomaticDisconnectChecker
	{
		private readonly ILogger _logger;

		public AutomaticDisconnectChecker(ILogger logger)
		{
			_logger = logger;
		}

		public bool DisconnectIfRequired(IRelayServerConnection connection)
		{
			if (connection.AbsoluteConnectionLifetime.HasValue && connection.ConnectedSince.HasValue)
			{
				var endOfMaximumConnectionTime = connection.ConnectedSince + connection.AbsoluteConnectionLifetime;

				if (DateTime.UtcNow > endOfMaximumConnectionTime)
				{
					connection.Disconnect();
					return true;
				}
			}

			if (connection.SlidingConnectionLifetime.HasValue && connection.LastActivity.HasValue)
			{
				var endOfSlidingConnectionTime = connection.LastActivity + connection.SlidingConnectionLifetime;

				if (DateTime.UtcNow > endOfSlidingConnectionTime)
				{<commit_msg>Added some logging to checker<commit_after>using System;
using Serilog;

namespace Thinktecture.Relay.OnPremiseConnector.SignalR
{
	internal class AutomaticDisconnectChecker: IAutomaticDisconnectChecker
	{
		private readonly ILogger _logger;

		public AutomaticDisconnectChecker(ILogger logger)
		{
			_logger = logger;
		}

		public bool DisconnectIfRequired(IRelayServerConnection connection)
		{
			if (connection.AbsoluteConnectionLifetime.HasValue && connection.ConnectedSince.HasValue)
			{
				_logger?.Debug("Checking if connection reached maximum absolute lifetime. relay-server-connection-instance-id={RelayServerConnectionInstanceId}", connection.RelayServerConnectionInstanceId);

				var endOfMaximumConnectionTime = connection.ConnectedSince + connection.AbsoluteConnectionLifetime;

				if (DateTime.UtcNow > endOfMaximumConnectionTime)
				{
					_logger?.Information("Connection reached maximum absolute lifetime: Disconnecting. relay-server-connection-instance-id={RelayServerConnectionInstanceId}", connection.RelayServerConnectionInstanceId);
					connection.Disconnect();
					return true;
				}
			}

			if (connection.SlidingConnectionLifetime.HasValue && connection.LastActivity.HasValue)
			{
				_logger?.Debug("Checking if connection reached maximum sliding lifetime. relay-server-connection-instance-id={RelayServerConnectionInstanceId}", connection.RelayServerConnectionInstanceId);

				var endOfSlidingConnectionTime = connection.LastActivity + connection.SlidingConnectionLifetime;

				if (DateTime.UtcNow > endOfSlidingConnectionTime)
				{
					_logger?.Information("Connection reached maximum sliding lifetime: Disconnecting. relay-server-connection-instance-id={RelayServerConnectionInstanceId}", connection.RelayServerConnectionInstanceId);

{'fraction_non_alphanumeric': 0.07369573148485954, 'fraction_numerical': 0.0, 'mean_word_length': 5.753694581280788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2655848', 'n_tokens_mistral': 833, 'n_tokens_neox': 712, 'n_words': 130}