Select Git revision
log_objects.js

Jake Read authored
log_objects.js 1.08 KiB
/*
debugger ! log anything !
*/
import { Hunkify, Input, Output, State } from '../hunks.js'
export default function ObjectLogger() {
Hunkify(this)
// hmm...
let tolog = this.input('reference', 'tolog')
let prefix = this.state('string', 'prefix', 'LOG:')
let logToConsole = this.state('boolean', 'console', true)
this.dom = {}
this.init = () => {
this.dom = $('<div>').get(0)
}
this.onload = () => {
//error here
let text = $('<div>').addClass('txt').append('- >').get(0)
$(this.dom).append(text)
}
this.loop = () => {
// this will be called once every round turn
// typically we check flow control first
if (tolog.io()) {
// an input is occupied, and the exit path is empty
let raw = tolog.get()
let stringRep
if (Array.isArray(raw)) {
stringRep = raw.join(', ')
} else if (typeof raw === "boolean") {
stringRep = raw.toString()
}
$(this.dom).children('.txt').html(stringRep)
if (logToConsole.value === true) {
console.log(this.ind, prefix.value, raw)
}
}
}
}