Add loglevel

This commit is contained in:
boryslevytskyi
2017-05-13 22:14:20 +03:00
parent c29a9029f2
commit ec908250cb
13 changed files with 187 additions and 20 deletions

View File

@@ -2,7 +2,8 @@ import React from 'react';
import * as expression from '../../expression';
import formatter from '../../formatter';
import BinaryStringView from './BinaryStringView';
import BitwiseExpressionViewModel from './models/BitwiseExpressionViewModel'
import BitwiseExpressionViewModel from './models/BitwiseExpressionViewModel';
import log from 'loglevel';
export default class BitwiseOperationEpxressionView extends React.Component {
render() {
@@ -23,12 +24,13 @@ export default class BitwiseOperationEpxressionView extends React.Component {
if(expr instanceof expression.SingleOperandExpression) {
const m = BitwiseExpressionViewModel.buildNot(expr, { emphasizeBytes: this.props.emphasizeBytes });
log.info('Render model', m);
return m.items.map((itm, i) => <ExpressionRow key={i} {...itm} emphasizeBytes={this.props.emphasizeBytes} maxNumberOfBits={m.maxNumberOfBits} />);
}
if(expr instanceof expression.MultipleOperandsExpression) {
const m = BitwiseExpressionViewModel.buildMultiple(expr, { emphasizeBytes: this.props.emphasizeBytes });
console.log('Render model', m);
log.info('Render model', m);
return m.items.map((itm, i) => <ExpressionRow key={i} {...itm} emphasizeBytes={this.props.emphasizeBytes} maxNumberOfBits={m.maxNumberOfBits} />);
}

View File

@@ -7,25 +7,45 @@ import cmd from './cmd';
import commands from './commands';
import AppRoot from './components/AppRoot';
import hash from './hash';
import log from 'loglevel';
setupLogger();
var stateData = appStateStore.getPersistedData();
const appState = new AppState(stateData);
appStateStore.watch(appState);
const appState = createAppState();
commands.initialize(cmd, appState);
console.log("appState", appState);
var hashArgs = hash.getArgs(window.location.hash);
var startupCommands = ['help', '1|2&6','1<<0x2a','2 4 8 16 32'];
if(hashArgs.commands.length > 0) {
startupCommands = hashArgs.commands;
}
startupCommands.forEach(cmd.execute.bind(cmd));
executeStartupCommands();
var root = <AppRoot appState={appState} />;
ReactDOM.render(root, document.getElementById('root'));
ReactDOM.render(root, document.getElementById('root'));
log.debug("started");
function createAppState() {
var stateData = appStateStore.getPersistedData();
const appState = new AppState(stateData);
appStateStore.watch(appState);
log.debug("appState", appState);
return appState;
}
function setupLogger() {
if(window.location.host != 'bitwisecmd.com' || window.location.hash.indexOf('-debug') > -1) {
log.setLevel("trace");
} else {
log.setLevel("warn");
}
}
function executeStartupCommands() {
var hashArgs = hash.getArgs(window.location.hash);
var startupCommands = ['help', '1|2&6','1<<0x2a','2 4 8 16 32'];
if(hashArgs.commands.length > 0) {
startupCommands = hashArgs.commands;
}
startupCommands.forEach(cmd.execute.bind(cmd));
}