<commit_before>const INITIAL_STATE = {
  logs: null,
};

// Actions
const APPEND_LOG_MESSAGE = 'APPEND_LOG_MESSAGE';

// Action Creators
export const appendLogMessage = message => ({ type: APPEND_LOG_MESSAGE, payload: message });

// Reducer
export default function reducer(state = INITIAL_STATE, action) {
  switch (action.type) {
    case APPEND_LOG_MESSAGE:
      return {
        ...state,
        logs: state.logs ? state.logs.concat(action.payload) : action.payload,
      };
    default:
      return state;
  }
}<commit_msg>Show last 500 log messages<commit_after>import { takeRight } from 'lodash';

const INITIAL_STATE = {
  logs: [],
};

// Actions
const APPEND_LOG_MESSAGE = 'APPEND_LOG_MESSAGE';

const exp = new RegExp(/(\{"message":.+"level":.+\})/g);

// Action Creators
export const appendLogMessage = message => ({ type: APPEND_LOG_MESSAGE, payload: message });

// Reducer
export default function reducer(state = INITIAL_STATE, action) {
  switch (action.type) {
    case APPEND_LOG_MESSAGE:
      // eslint-disable-next-line no-case-declarations
      const logs = action.payload.replace(/},{/g, '}\n{').match(exp);

      return {
        ...state,
        logs: takeRight([...state.logs, ...logs], 500),
      };
    default:
      return state;
  }
}
{'fraction_non_alphanumeric': 0.14454045561665357, 'fraction_numerical': 0.004713275726630008, 'mean_word_length': 3.1907894736842106, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '523867', 'n_tokens_mistral': 423, 'n_tokens_neox': 403, 'n_words': 93}