<commit_before>﻿using Fleck;
using WampSharp.Core.Listener;
using WampSharp.V2.Binding;
using WampSharp.V2.Transports;

namespace WampSharp.Fleck
{
    /// <summary>
    /// Represents a WebSocket transport implemented with Fleck.
    /// </summary>
    public class FleckWebSocketTransport : WebSocketTransport<IWebSocketConnection>
    {
        private readonly WebSocketServer mServer;

        /// <summary>
        /// Creates a new instance of <see cref="FleckWebSocketTransport"/>
        /// given the server address to run at.
        /// </summary>
        /// <param name="location">The given server address.</param>
        public FleckWebSocketTransport(string location)
        {
            mServer = new WebSocketServer(location);
        }

        protected override void OpenConnection<TMessage>(IWampConnection<TMessage> connection)
        {
        }

        public override void Dispose()<commit_msg>Routing Fleck logs to LibLog<commit_after>﻿using System;
using Fleck;
using WampSharp.Core.Listener;
using WampSharp.Logging;
using WampSharp.V2.Binding;
using WampSharp.V2.Transports;
using LogLevel = Fleck.LogLevel;

namespace WampSharp.Fleck
{
    /// <summary>
    /// Represents a WebSocket transport implemented with Fleck.
    /// </summary>
    public class FleckWebSocketTransport : WebSocketTransport<IWebSocketConnection>
    {
        private readonly WebSocketServer mServer;

        /// <summary>
        /// Creates a new instance of <see cref="FleckWebSocketTransport"/>
        /// given the server address to run at.
        /// </summary>
        /// <param name="location">The given server address.</param>
        public FleckWebSocketTransport(string location)
        {
            mServer = new WebSocketServer(location);

            RouteLogs();
        }

        private void RouteLogs()
        {
            Action<LogLevel, string, Exception> logAction = FleckLog.LogAction;

            if (logAction != null &&
                logAction.Method.DeclaringType == typeof (FleckLog))
            {
                FleckLog.LogAction = ConvertLog;
            }
        }

        private void ConvertLog(LogLevel logLevel, string message, Exception exception)
        {
            switch (logLevel)
            {
                case LogLevel.Debug:
                {
                    mLogger.DebugException(message, exception);
                    break;
                }
                case LogLevel.Info:
                {
                    mLogger.InfoException(message, exception);
                    break;
                }
                case LogLevel.Warn:
                {
                    mLogger.WarnException(message, exception);
                    break;
                }
                case LogLevel.Error:
                {
                    mLogger.ErrorException(message, exception);
                    break;
                }
            }
        }

        protected override void OpenConnection<TMessage>(IWampConnection<TMessage> connection)
        {
        }

        public override void Dispose()
{'fraction_non_alphanumeric': 0.08612903225806452, 'fraction_numerical': 0.0012903225806451613, 'mean_word_length': 1.7225636523266024, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, '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': '418304', 'n_tokens_mistral': 793, 'n_tokens_neox': 755, 'n_words': 183}