Skip to content

Commit

Permalink
Merge pull request #7 from carbonblack/add-safe-logging-for-tables
Browse files Browse the repository at this point in the history
Add log check to logTable method
  • Loading branch information
snowak-cb authored Aug 21, 2017
2 parents 6460284 + 3b50df9 commit 9502267
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
Binary file modified dist/dist-min.tar.gz
Binary file not shown.
Binary file modified dist/dist-min.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/dist-min/react-console.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dist-min/react-console.min.js.map

Large diffs are not rendered by default.

Binary file modified dist/dist.tar.gz
Binary file not shown.
Binary file modified dist/dist.zip
Binary file not shown.
20 changes: 10 additions & 10 deletions dist/dist/react-console.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/dist/react-console.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions lib/react-console.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/react-console.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/react-console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,29 +229,29 @@ export default class extends React.Component<ConsoleProps,ConsoleState> {
setBusy = () => {
this.setState({acceptInput: false});
}
updateLastLog = (...messages: any[]) => {
let log = this.state.log;
if(!log.length){
log.push({label: '', command: '', message: [] });
getSafeLog = () => {
if(!this.state.log.length){
this.state.log.push({label: '', command: '', message: [] });
}
return this.state.log;
}
updateLastLog = (...messages: any[]) => {
let log = this.getSafeLog();
let indexToReplace = log[this.state.log.length-1].message.length > 0 ? log[this.state.log.length-1].message.length - 1 : 0;
log[this.state.log.length-1].message[indexToReplace] = {value: messages};
this.setState({
log: log,
}, this.scrollIfBottom() );
}
log = (...messages: any[]) => {
let log = this.state.log;
if(!log.length){
log.push({label: '', command: '', message: [] });
}
let log = this.getSafeLog();
log[this.state.log.length-1].message.push({value: messages});
this.setState({
log: log,
}, this.scrollIfBottom() );
}
logX = (type: string, ...messages: any[]) => {
let log = this.state.log;
let log = this.getSafeLog();
if(!log.length){
log.push({label: '', command: '', message: [] });
}
Expand All @@ -261,7 +261,7 @@ export default class extends React.Component<ConsoleProps,ConsoleState> {
}, this.scrollIfBottom() );
}
logTable = (tableData: ConsoleTableObject, type?: string) => {
let log = this.state.log;
let log = this.getSafeLog();
if(type){
log[this.state.log.length-1].message.push({isTable: true, type: type, value: [tableData]});
}else{
Expand Down

0 comments on commit 9502267

Please sign in to comment.