<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JavaScriptViewEngine;
using Microsoft.AspNet.Hosting;
using System.IO;

namespace React.Services
{
    public class ReactEnvironmentInitializer : IJsEngineInitializer
    {
        private IHostingEnvironment _hostingEnvironment;

        public ReactEnvironmentInitializer(IHostingEnvironment hostingEnvironment)
        {
            _hostingEnvironment = hostingEnvironment;
        }

        public void Initialize(IJsEngine engine)
        {
            engine.ExecuteFile(Path.Combine(_hostingEnvironment.WebRootPath, "pack", "server.generated.js"));
        }
    }
}<commit_msg>Log errors if we couldn't initialize the react server-side environment.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JavaScriptViewEngine;
using Microsoft.AspNet.Hosting;
using System.IO;
using Microsoft.Extensions.Logging;

namespace React.Services
{
    public class ReactEnvironmentInitializer : IJsEngineInitializer
    {
        private IHostingEnvironment _hostingEnvironment;
        private ILogger _logger;

        public ReactEnvironmentInitializer(IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
        {
            _hostingEnvironment = hostingEnvironment;
            _logger = loggerFactory.CreateLogger<ReactEnvironmentInitializer>();
        }

        public void Initialize(IJsEngine engine)
        {
            try
            {
                engine.ExecuteFile(Path.Combine(_hostingEnvironment.WebRootPath, "pack", "server.generated.js"));
            }
            catch (Exception ex)
            {
                _logger.LogError("Could not initialize the React server-side environment.", ex);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07219827586206896, 'fraction_numerical': 0.0, 'mean_word_length': 3.0194805194805197, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2488531', 'n_tokens_mistral': 451, 'n_tokens_neox': 451, 'n_words': 100}