Skip to content

Commit

Permalink
Merge pull request #155 from ipfs/bows
Browse files Browse the repository at this point in the history
feat: Replace console.log with debug
  • Loading branch information
RichardLitt committed Jan 3, 2016
2 parents 59e3719 + 35505ba commit 9327e46
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 20 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 @@ -7,7 +7,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', () => {
Expand Down
9 changes: 6 additions & 3 deletions app/scripts/include/globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/

import THREE from 'three'
import debug from 'debug'

const log = debug('globe:scripts')

export default function (container, opts) {
opts = opts || {}
Expand Down Expand Up @@ -248,11 +251,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 @@ -3,11 +3,14 @@ import ReactDOM from 'react-dom'
import $ from 'jquery'
import {Row, Col, Nav, NavItem, Panel} from 'react-bootstrap'
import {LinkContainer} from 'react-router-bootstrap'
import debug from 'debug'

import FileList from '../views/filelist'
import LocalStorage from '../utils/localStorage'
import i18n from '../utils/i18n.js'

const log = debug('pages:files')

export default React.createClass({
displayName: 'Files',
propTypes: {
Expand Down Expand Up @@ -53,15 +56,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 @@ -81,7 +84,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 debug from 'debug'

import DHTGraph from '../views/dhtgraph'

const log = debug('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
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 debug from 'debug'

const log = debug('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 debug from 'debug'
import _ from 'lodash'
// Displays webgl warning message if not present
require('../include/Detector.js')

const debug = Debug('ipfs:pages:connections')
const log = debug('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 @@ -5,7 +5,6 @@
"dependencies": {
"bootstrap": "^3.3.5",
"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 Expand Up @@ -34,6 +33,7 @@
"babel-preset-stage-0": "^6.3.13",
"chai": "^3.4.1",
"css-loader": "^0.23.0",
"debug": "^2.2.0",
"eslint": "^1.10.3",
"eslint-config-standard": "^4.4.0",
"eslint-config-standard-react": "^1.2.1",
Expand Down

0 comments on commit 9327e46

Please sign in to comment.