<commit_before>import React from 'react'

import 'babel-polyfill'
import 'inert-polyfill'

import '../styles/bootstrap.min.css'
import '../styles/font-awesome.css'
import '../styles/app.css'

import { render } from 'react-dom'
import { Provider } from 'react-redux'

import routes from './routes'
import { ThemeProvider } from 'styled-components'
import theme from '@styled/theme'

import log4js from 'log4js'
import { authorizationHeaderValue } from './utils/api-utils'
import { configureLogging } from './utils/logging-utils'
import store from './store'

const state = store.getState()
const coreAPIPassword = state.settings.api.coreAPIPassword
const logServerPort = state.settings.api.logServerPort

configureLogging(
  log4js,
  logServerPort,
  authorizationHeaderValue(coreAPIPassword),
  process.env.NODE_ENV
)

let logger = log4js.getLogger(__filename)

window.addEventListener('error', event => {
  // eslint-disable-next-line
  logger = log4js.getLogger("window.addWindowListener('error')")
  logger.error(event)
})

window.onerror = (messageOrEvent, source, lineno, colno, error) => {
  logger = log4js.getLogger('window.onerror')
  logger.error(messageOrEvent, error)
}

configureLogging(
  log4js,
  logServerPort,
  authorizationHeaderValue(coreAPIPassword),
  process.env.NODE_ENV
)

if (process.env.NODE_ENV === 'production') {
  if ('serviceWorker' in navigator) {
    window.addEventListener('load', async () => {
      try {
        const registration = await navigator.serviceWorker.register(
          '/static/js/sw.js'
        )
        console.log('SW registered: ', registration)
      } catch (registrationError) {
        console.log('SW registration failed: ', registrationError)
      }
    })
  }
}

window.addEventListener('error', event => {
  // eslint-disable-next-line
  logger = log4js.getLogger("window.addWindowListener('error')")
  logger.error(event)
})

window.onerror = (messageOrEvent, source, lineno, colno, error) => {
  logger = log4js.getLogger('window.onerror')
  logger.error(messageOrEvent, error)
}

if (process.env.NODE_ENV !== 'production') {
  logger.info('NODE_ENV is not production')
  logger.debug('Enabling React devtools')
  window.React = React
}
render(
  <Provider store={store}>
    <ThemeProvider theme={theme}>{routes}</ThemeProvider>
  </Provider>,<commit_msg>don't use console.log for sw messages<commit_after>import React from 'react'

import 'babel-polyfill'
import 'inert-polyfill'

import '../styles/bootstrap.min.css'
import '../styles/font-awesome.css'
import '../styles/app.css'

import { render } from 'react-dom'
import { Provider } from 'react-redux'

import routes from './routes'
import { ThemeProvider } from 'styled-components'
import theme from '@styled/theme'

import log4js from 'log4js'
import { authorizationHeaderValue } from './utils/api-utils'
import { configureLogging } from './utils/logging-utils'
import store from './store'

const state = store.getState()
const coreAPIPassword = state.settings.api.coreAPIPassword
const logServerPort = state.settings.api.logServerPort

configureLogging(
  log4js,
  logServerPort,
  authorizationHeaderValue(coreAPIPassword),
  process.env.NODE_ENV
)

let logger = log4js.getLogger(__filename)

window.addEventListener('error', event => {
  // eslint-disable-next-line
  logger = log4js.getLogger("window.addWindowListener('error')")
  logger.error(event)
})

window.onerror = (messageOrEvent, source, lineno, colno, error) => {
  logger = log4js.getLogger('window.onerror')
  logger.error(messageOrEvent, error)
}

configureLogging(
  log4js,
  logServerPort,
  authorizationHeaderValue(coreAPIPassword),
  process.env.NODE_ENV
)

if (process.env.NODE_ENV === 'production') {
  if ('serviceWorker' in navigator) {
    window.addEventListener('load', async () => {
      try {
        const registration = await navigator.serviceWorker.register(
          '/static/js/sw.js'
        )
        logger.log('SW registered: ', registration)
      } catch (registrationError) {
        logger.log('SW registration failed: ', registrationError)
      }
    })
  }
}

window.addEventListener('error', event => {
  // eslint-disable-next-line
  logger = log4js.getLogger("window.addWindowListener('error')")
  logger.error(event)
})

window.onerror = (messageOrEvent, source, lineno, colno, error) => {
  logger = log4js.getLogger('window.onerror')
  logger.error(messageOrEvent, error)
}

if (process.env.NODE_ENV !== 'production') {
  logger.info('NODE_ENV is not production')
  logger.debug('Enabling React devtools')
  window.React = React
}
render(
  <Provider store={store}>
    <ThemeProvider theme={theme}>{routes}</ThemeProvider>
  </Provider>,
{'fraction_non_alphanumeric': 0.13735558408215662, 'fraction_numerical': 0.0038510911424903724, 'mean_word_length': 4.392156862745098, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '3897313', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1458, 'n_words': 296}