Skip to content

Commit

Permalink
feat: Replace console.log and debug with bows
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jan 1, 2016
1 parent 485a978 commit c38b743
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"parser": "babel-eslint",
"extends": ["standard", "standard-react"]
"extends": ["standard", "standard-react"],
"env": {
"browser": true
}
}
2 changes: 1 addition & 1 deletion app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import routes from './routes'
require('../styles/app.less')

if (process.env.NODE_ENV !== 'production') {
window.uiDebug = require('debug')
localStorage.debug = true
}

document.addEventListener('DOMContentLoaded', function () {
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/include/globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ export default function (container, opts) {
}))
} else {
if (this._baseGeometry.morphTargets.length < 8) {
console.log('t l', this._baseGeometry.morphTargets.length)
log('t l', this._baseGeometry.morphTargets.length)
var padding = 8 - this._baseGeometry.morphTargets.length
console.log('padding', padding)
log('padding', padding)
for (var i = 0; i <= padding; i++) {
console.log('padding', i)
log('padding', i)
this._baseGeometry.morphTargets.push({
'name': 'morphPadding' + i,
vertices: this._baseGeometry.vertices
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/pages/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default React.createClass({
},
getInitialState: function () {
this.props.ipfs.config.show((err, configStream) => {
if (err) return console.log(err)
if (err) return console.error(err)

this.setState({
config: JSON.parse(configStream.toString())
Expand Down
9 changes: 6 additions & 3 deletions app/scripts/pages/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import LocalStorage from '../utils/localStorage'
import $ from 'jquery'
import i18n from '../utils/i18n.js'
import {Row, Col, Nav, Panel} from 'react-bootstrap'
import bows from 'bows'

const log = bows('pages:files')

export default React.createClass({
displayName: 'Files',
Expand Down Expand Up @@ -50,15 +53,15 @@ export default React.createClass({
},

onDragOver: function (e) {
console.log('dragover')
log('dragover')
this.setState({ dragging: true })
$(e.target).addClass('hover')
e.stopPropagation()
e.preventDefault()
},

onDragLeave: function (e) {
console.log('dragleave')
log('dragleave')
this.setState({ dragging: false })
$(e.target).removeClass('hover')
e.stopPropagation()
Expand All @@ -78,7 +81,7 @@ export default React.createClass({
if (!files || !files[0]) return
var file = files[0]
var t = this
console.log('adding file: ', file)
log('adding file: ', file)

function add (data) {
t.props.ipfs.add(data, function (err, res) {
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/pages/routing.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import {Row, Col} from 'react-bootstrap'
import bows from 'bows'

import DHTGraph from '../views/dhtgraph'

const log = bows('pages:routing')

var base58Chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
var base58Index = {}
for (var i = 0; i < base58Chars.length; i++) {
Expand Down Expand Up @@ -40,7 +44,7 @@ export default React.createClass({
}
})

console.log(peers)
log('peers', peers)
t.setState({ peers: peers })
})
})
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/views/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export default React.createClass({
saving: true
})

console.log(t.state.body)

t.props.ipfs.config.replace(new Buffer(t.state.body), function (err) {
var newState = { saving: false }
if (err) {
Expand Down
7 changes: 5 additions & 2 deletions app/scripts/views/editable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react'
import $ from 'jquery'
import bows from 'bows'

const log = bows('editable')

function format (value) {
value = value.trim()
Expand Down Expand Up @@ -56,10 +59,10 @@ export default React.createClass({

submit: function (value) {
this.props.value = value
console.log(value)

this.props.ipfs.config.set(this.props.key, value, function (err, res) {
console.log(err, res)
if (err) return console.error(err)
log('submitted:', res)
})
},

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default React.createClass({
if (!hash) hash = el.parent().attr('data-hash')

this.props.ipfs.pin.remove(hash, {r: true}, function (err, res) {
console.log(err, res)
if (err) return console.error(err)
})
},

Expand Down
10 changes: 5 additions & 5 deletions app/scripts/views/globe.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import DATGlobe from '../include/globe.js'
import LocalStorageMixin from 'react-localstorage'
import Debug from 'debug'
import bows from 'bows'
import _ from 'lodash'
// Displays webgl warning message if not present
require('../include/Detector.js')

const debug = Debug('ipfs:pages:connections')
const log = bows('globe')

export default React.createClass({
displayName: 'Globe',
Expand All @@ -31,7 +31,7 @@ export default React.createClass({

componentDidUpdate: function (prevProps, prevState) {
if (prevState.theme !== this.state.theme) {
debug('disposing globe')
log('disposing globe')
this.globe && this.globe.dispose()
this.createGlobe()
}
Expand All @@ -44,7 +44,7 @@ export default React.createClass({
if (!this.globe || !data.length) return
// TODO find difference between old points and new points
// and only add the new ones. THREE might be doing this internally.
debug('adding %d points, %j', data.length, data)
log('adding %d points, %j', data.length, data)
this.globe.addData(data, { format: 'magnitude' })
this.globe.createPoints()
},
Expand All @@ -54,7 +54,7 @@ export default React.createClass({
var texturePath = window.location.pathname + slash + 'img/'
if (this.state.theme === 'dark') texturePath += 'dark-'

debug('mounting globe')
log('mounting globe')
this.globe = new DATGlobe(this.refs.globe, {
imgDir: texturePath
})
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/nodeprops.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {addr} from './typography'
export default React.createClass({
render: function () {
var node = this.props || {}
console.log(node)

var table = [
['Node ID', addr(node.ID)],
['Version', addr(node.AgentVersion)]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "A frontend for IPFS",
"dependencies": {
"bootstrap": "^3.3.5",
"bows": "^1.4.8",
"d3": "^3.5.6",
"debug": "^2.2.0",
"font-awesome": "^4.5.0",
"i18next": "^2.0.5",
"i18next-browser-languagedetector": "^0.0.11",
Expand Down

0 comments on commit c38b743

Please sign in to comment.