Skip to content

Commit c83973f

Browse files
committed
rename sprint => structuredprint
also log events listened for.
1 parent c85bcb6 commit c83973f

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

src/background.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import {
99
MENUITEM_BLOCK,
1010
MENUITEM_GENERATE
1111
} from './constants'
12-
import {sprint, formatmsat, notify, abbreviate} from './utils'
12+
import {structuredprint, formatmsat, notify, abbreviate} from './utils'
1313
import {getBehavior} from './predefined-behaviors'
1414
import {handleRPC, listenForEvents} from './interfaces'
1515
import * as current from './current-action'
1616

1717
// logger service
1818
browser.runtime.onMessage.addListener((message, sender) => {
1919
console.log(
20-
`[message-in]: ${sprint({
20+
`[message-in]: ${structuredprint({
2121
...message,
2222
tab: message.getInit ? '-' : (sender.tab || message.tab).id
2323
})}}`
@@ -77,6 +77,8 @@ browser.runtime.onMessage.addListener(({setAction, tab}, sender) => {
7777

7878
// start listening for events from the node
7979
listenForEvents((type, data) => {
80+
console.log(`[node-event][${type}]: ${structuredprint(data)}`)
81+
8082
switch (type) {
8183
case 'payment-received':
8284
let {amount, description, hash} = data

src/content.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import browser from 'webextension-polyfill'
55
const Keysim = require('keysim')
66

77
import {PROMPT_PAYMENT, REQUEST_GETINFO} from './constants'
8-
import {getOriginData, rpcParamsAreSet, sprint} from './utils'
8+
import {getOriginData, rpcParamsAreSet, structuredprint} from './utils'
99

1010
if (document) {
1111
// intercept any `lightning:` links
@@ -125,7 +125,7 @@ if (document) {
125125
})
126126
} else {
127127
// default: an action or prompt
128-
console.log(`[kWh]: ${type} ${sprint(extra)} ${sprint(origin)}`)
128+
console.log(`[kWh]: ${type} ${structuredprint(extra)} ${structuredprint(origin)}`)
129129

130130
switch (type) {
131131
case REQUEST_GETINFO:

src/interfaces/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as lightningd_spark from './lightningd_spark'
44
import * as eclair from './eclair'
55
import * as ptarmigan from './ptarmigan'
6-
import {getRpcParams, sprint} from '../utils'
6+
import {getRpcParams, structuredprint} from '../utils'
77

88
const kinds = {
99
lightningd_spark,
@@ -15,7 +15,7 @@ export function handleRPC(rpcField = {}) {
1515
return getRpcParams().then(({kind}) => {
1616
for (let method in rpcField) {
1717
let args = rpcField[method]
18-
console.log(`[rpc][${kind}]: ${method} ${sprint(args)}`)
18+
console.log(`[rpc][${kind}]: ${method} ${structuredprint(args)}`)
1919
return kinds[kind][method].apply(null, args)
2020
}
2121
})

src/popup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Home from './components/Home'
1616
import Payment from './components/Payment'
1717
import Invoice from './components/Invoice'
1818
import {RPCParams} from './options'
19-
import {sprint, rpcParamsAreSet} from './utils'
19+
import {structuredprint, rpcParamsAreSet} from './utils'
2020

2121
export const CurrentContext = React.createContext({action: null, tab: null})
2222

@@ -32,7 +32,7 @@ function App() {
3232
useEffect(() => {
3333
// when this page is rendered, query the current action
3434
browser.runtime.sendMessage({getInit: true}).then(({action, tab}) => {
35-
console.log(`[action]: ${sprint(action)} tab=${tab.id}`)
35+
console.log(`[action]: ${structuredprint(action)} tab=${tab.id}`)
3636
setAction(action)
3737
setProxiedTab(tab)
3838
})

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function formatmsat(msatoshis) {
101101
}
102102
}
103103

104-
export function sprint(o) {
104+
export function structuredprint(o) {
105105
return Object.keys(o)
106106
.map(
107107
k => `${k}='${typeof o[k] === 'string' ? o[k] : JSON.stringify(o[k])}'`

0 commit comments

Comments
 (0)