import { ansiToJson } from 'anser'; import * as Constants from 'app/common/constants'; import * as Strings from 'app/common/strings'; import hasAnsi from 'has-ansi'; import React from 'react'; import { css, cx } from 'react-emotion'; import StackTrace from './StackTrace'; const STYLES_LOG = css` font-family: ${Constants.fontFamilies.mono}; display: flex; justify-content: flex-start; font-size: 12px; margin-bottom: 12px; `; const STYLES_LOG_COL_TIMESTAMP = css` color: ${Constants.colors.logTimestamp}; flex-shrink: 0; font-size: 10px; margin: 0 8px 4px 0; overflow-wrap: break-word; `; const STYLES_LOG_COL_CONTEXT = css` color: ${Constants.colors.logContext}; flex-shrink: 0; font-size: 10px; margin: 0 8px 4px 0; text-transform: uppercase; overflow-wrap: break-word; margin-right: 8px; `; const STYLES_LOG_COL_CONTENT = css` font-family: ${Constants.fontFamilies.mono}; width: 100%; min-width: 25%; line-height: 14px; overflow-wrap: break-word; white-space: pre-wrap; `; const STYLES_LOG_LEFT = css` flex-shrink: 0; width: 64px; `; const STYLES_LOG_COL_LEVEL = css` flex-shrink: 0; font-size: 10px; margin: 1px 8px 4px 0; text-transform: uppercase; overflow-wrap: break-word; margin-right: 8px; `; const logLevelLabel = level => { switch (level) { case 'DEBUG': return 'Debug'; case 'INFO': return 'Info'; case 'WARN': return 'Warning'; case 'ERROR': return 'Error'; } }; export default class Log extends React.Component { renderMessageContent({ msg, level }) { if (!hasAnsi(msg)) { return (