Skip to content

Commit 9327e46

Browse files
committedJan 3, 2016
Merge pull request #155 from ipfs/bows
feat: Replace console.log with debug
2 parents 59e3719 + 35505ba commit 9327e46

File tree

11 files changed

+36
-20
lines changed

11 files changed

+36
-20
lines changed
 

‎.eslintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"parser": "babel-eslint",
3-
"extends": ["standard", "standard-react"]
3+
"extends": ["standard", "standard-react"],
4+
"env": {
5+
"browser": true
6+
}
47
}

‎app/scripts/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import routes from './routes'
77
require('../styles/app.less')
88

99
if (process.env.NODE_ENV !== 'production') {
10-
window.uiDebug = require('debug')
10+
localStorage.debug = true
1111
}
1212

1313
document.addEventListener('DOMContentLoaded', () => {

‎app/scripts/include/globe.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313

1414
import THREE from 'three'
15+
import debug from 'debug'
16+
17+
const log = debug('globe:scripts')
1518

1619
export default function (container, opts) {
1720
opts = opts || {}
@@ -248,11 +251,11 @@ export default function (container, opts) {
248251
}))
249252
} else {
250253
if (this._baseGeometry.morphTargets.length < 8) {
251-
console.log('t l', this._baseGeometry.morphTargets.length)
254+
log('t l', this._baseGeometry.morphTargets.length)
252255
var padding = 8 - this._baseGeometry.morphTargets.length
253-
console.log('padding', padding)
256+
log('padding', padding)
254257
for (var i = 0; i <= padding; i++) {
255-
console.log('padding', i)
258+
log('padding', i)
256259
this._baseGeometry.morphTargets.push({
257260
'name': 'morphPadding' + i,
258261
vertices: this._baseGeometry.vertices

‎app/scripts/pages/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default React.createClass({
99
},
1010
getInitialState: function () {
1111
this.props.ipfs.config.show((err, configStream) => {
12-
if (err) return console.log(err)
12+
if (err) return console.error(err)
1313

1414
this.setState({
1515
config: JSON.parse(configStream.toString())

‎app/scripts/pages/files.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import ReactDOM from 'react-dom'
33
import $ from 'jquery'
44
import {Row, Col, Nav, NavItem, Panel} from 'react-bootstrap'
55
import {LinkContainer} from 'react-router-bootstrap'
6+
import debug from 'debug'
67

78
import FileList from '../views/filelist'
89
import LocalStorage from '../utils/localStorage'
910
import i18n from '../utils/i18n.js'
1011

12+
const log = debug('pages:files')
13+
1114
export default React.createClass({
1215
displayName: 'Files',
1316
propTypes: {
@@ -53,15 +56,15 @@ export default React.createClass({
5356
},
5457

5558
onDragOver: function (e) {
56-
console.log('dragover')
59+
log('dragover')
5760
this.setState({ dragging: true })
5861
$(e.target).addClass('hover')
5962
e.stopPropagation()
6063
e.preventDefault()
6164
},
6265

6366
onDragLeave: function (e) {
64-
console.log('dragleave')
67+
log('dragleave')
6568
this.setState({ dragging: false })
6669
$(e.target).removeClass('hover')
6770
e.stopPropagation()
@@ -81,7 +84,7 @@ export default React.createClass({
8184
if (!files || !files[0]) return
8285
var file = files[0]
8386
var t = this
84-
console.log('adding file: ', file)
87+
log('adding file: ', file)
8588

8689
function add (data) {
8790
t.props.ipfs.add(data, function (err, res) {

‎app/scripts/pages/routing.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from 'react'
22
import {Row, Col} from 'react-bootstrap'
3+
import debug from 'debug'
4+
35
import DHTGraph from '../views/dhtgraph'
46

7+
const log = debug('pages:routing')
8+
59
var base58Chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
610
var base58Index = {}
711
for (var i = 0; i < base58Chars.length; i++) {
@@ -40,7 +44,7 @@ export default React.createClass({
4044
}
4145
})
4246

43-
console.log(peers)
47+
log('peers', peers)
4448
t.setState({ peers: peers })
4549
})
4650
})

‎app/scripts/views/editable.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from 'react'
22
import $ from 'jquery'
3+
import debug from 'debug'
4+
5+
const log = debug('editable')
36

47
function format (value) {
58
value = value.trim()
@@ -56,10 +59,10 @@ export default React.createClass({
5659

5760
submit: function (value) {
5861
this.props.value = value
59-
console.log(value)
6062

6163
this.props.ipfs.config.set(this.props.key, value, function (err, res) {
62-
console.log(err, res)
64+
if (err) return console.error(err)
65+
log('submitted:', res)
6366
})
6467
},
6568

‎app/scripts/views/filelist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default React.createClass({
2020
if (!hash) hash = el.parent().attr('data-hash')
2121

2222
this.props.ipfs.pin.remove(hash, {r: true}, function (err, res) {
23-
console.log(err, res)
23+
if (err) return console.error(err)
2424
})
2525
},
2626

‎app/scripts/views/globe.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react'
22
import DATGlobe from '../include/globe.js'
33
import LocalStorageMixin from 'react-localstorage'
4-
import Debug from 'debug'
4+
import debug from 'debug'
55
import _ from 'lodash'
66
// Displays webgl warning message if not present
77
require('../include/Detector.js')
88

9-
const debug = Debug('ipfs:pages:connections')
9+
const log = debug('globe')
1010

1111
export default React.createClass({
1212
displayName: 'Globe',
@@ -31,7 +31,7 @@ export default React.createClass({
3131

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

57-
debug('mounting globe')
57+
log('mounting globe')
5858
this.globe = new DATGlobe(this.refs.globe, {
5959
imgDir: texturePath
6060
})

‎app/scripts/views/nodeprops.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {addr} from './typography'
55
export default React.createClass({
66
render: function () {
77
var node = this.props || {}
8-
console.log(node)
8+
99
var table = [
1010
['Node ID', addr(node.ID)],
1111
['Version', addr(node.AgentVersion)]

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"dependencies": {
66
"bootstrap": "^3.3.5",
77
"d3": "^3.5.6",
8-
"debug": "^2.2.0",
98
"font-awesome": "^4.5.0",
109
"i18next": "^2.0.5",
1110
"i18next-browser-languagedetector": "^0.0.11",
@@ -34,6 +33,7 @@
3433
"babel-preset-stage-0": "^6.3.13",
3534
"chai": "^3.4.1",
3635
"css-loader": "^0.23.0",
36+
"debug": "^2.2.0",
3737
"eslint": "^1.10.3",
3838
"eslint-config-standard": "^4.4.0",
3939
"eslint-config-standard-react": "^1.2.1",

0 commit comments

Comments
 (0)
Please sign in to comment.