Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #3554 from brave/add-additional-publisher-debugging
Browse files Browse the repository at this point in the history
a few minor things
  • Loading branch information
mrose17 authored Aug 30, 2016
2 parents f5496f0 + badbafd commit 84eceee
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,6 @@ eventStore.addChangeListener(() => {
var entry, faviconURL, publisher
var location = page.url

/*
console.log('\npage=' + JSON.stringify(page, null, 2))
*/
if ((location.match(/^about/)) || ((locations[location]) && (locations[location].publisher))) return

if (!page.publisher) {
Expand Down Expand Up @@ -403,6 +400,7 @@ var enable = (onoff) => {
} catch (ex) {
console.log('synopsisPath parse error: ' + ex.toString())
}
if (process.env.NODE_ENV === 'test') synopsis.options.minDuration = 0
underscore.keys(synopsis.publishers).forEach((publisher) => {
if (synopsis.publishers[publisher].faviconURL === null) delete synopsis.publishers[publisher].faviconURL
})
Expand Down Expand Up @@ -471,12 +469,14 @@ var updatePublisherInfo = () => {
publisherInfo.synopsis = synopsisNormalizer()

if (publisherInfo._internal.debugP) {
/*
data = []
publisherInfo.synopsis.forEach((entry) => {
data.push(underscore.extend(underscore.omit(entry, [ 'faviconURL' ]), { faviconURL: entry.faviconURL && '...' }))
})
console.log('\nupdatePublisherInfo: ' + JSON.stringify(data, null, 2))
*/
}

appActions.updatePublisherInfo(underscore.omit(publisherInfo, [ '_internal' ]))
Expand Down Expand Up @@ -584,9 +584,10 @@ var visit = (location, timestamp) => {

if (!synopsis) return

/*
console.log('locations[' + currentLocation + ']=' + JSON.stringify(locations[currentLocation], null, 2))
*/
if (publisherInfo._internal.debugP) {
console.log('locations[' + currentLocation + ']=' + JSON.stringify(locations[currentLocation], null, 2) +
' duration=' + (timestamp - currentTimestamp) + ' msec')
}
if ((location === currentLocation) || (!locations[currentLocation])) return

publisher = locations[currentLocation].publisher
Expand All @@ -596,6 +597,7 @@ var visit = (location, timestamp) => {
publishers[publisher][currentLocation] = timestamp

duration = timestamp - currentTimestamp
if (publisherInfo._internal.debugP) console.log('\nadd publisher ' + publisher + ': ' + duration + ' msec')
synopsis.addPublisher(publisher, duration)
updatePublisherInfo()
}
Expand Down Expand Up @@ -795,7 +797,7 @@ var callback = (err, result, delayTime) => {
}

if (err) {
console.log('ledger client error(1): ' + err.toString() + (err.stack ? ('\n' + err.stack) : ''))
console.log('ledger client error(1): ' + JSON.stringify(err, null, 2) + (err.stack ? ('\n' + err.stack) : ''))
if (!client) return

if (typeof delayTime === 'undefined') delayTime = random.randomInt({ min: 1, max: 10 * msecs.minute })
Expand Down Expand Up @@ -1105,7 +1107,7 @@ var syncWriter = (path, obj, options, cb) => {
})
}

const pathSuffix = (process.env.NODE_ENV === 'development') ? '-dev' : ''
const pathSuffix = { development: '-dev', test: '-test' }[process.env.NODE_ENV] || ''

var pathName = (name) => {
var parts = path.parse(name)
Expand Down

0 comments on commit 84eceee

Please sign in to comment.