Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 2622586

Browse files
committed
Remove file logic from log action
1 parent 0cf4a79 commit 2622586

File tree

2 files changed

+0
-92
lines changed

2 files changed

+0
-92
lines changed

src/action/log.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { MAX_LOG_LENGTH } from '../config';
1010
let _store;
1111
let _ipc;
1212
let _printErrObj;
13-
let _FS;
14-
let _Share;
1513

1614
/**
1715
* Log an info event e.g. when something relevant but non-critical happens.
@@ -51,49 +49,6 @@ export function error(...args) {
5149
_ipc && _ipc.send('log-error', null, args);
5250
}
5351

54-
/**
55-
* Gets the location of the LND log file as a string.
56-
* @param {string} network The network the user's on
57-
* @return {string}
58-
*/
59-
export function getLogPath(network) {
60-
if (!_FS) {
61-
throw new Error('Cannot get log path with no FS in action/log.js');
62-
}
63-
const lndDir = _FS.DocumentDirectoryPath;
64-
return `${lndDir}/logs/bitcoin/${network}/lnd.log`;
65-
}
66-
67-
/**
68-
* Retrieves the entire LND log file as a string.
69-
* @return {Promise<string>}
70-
*/
71-
export async function getLogs() {
72-
if (!_FS) {
73-
throw new Error('Cannot get logs with no FS in action/log.js');
74-
}
75-
return _FS.readFile(getLogPath(_store.network), 'utf8');
76-
}
77-
78-
/**
79-
* Shares the log file using whatever native share function we have.
80-
* @return {Promise}
81-
*/
82-
export async function shareLogs() {
83-
try {
84-
if (!_Share) {
85-
throw new Error('Cannot share logs with no Share in action/log.js');
86-
}
87-
const logs = await getLogs();
88-
return _Share.share({
89-
title: 'Lightning App logs',
90-
message: logs,
91-
});
92-
} catch (err) {
93-
error(err.message);
94-
}
95-
}
96-
9752
function pushLogs(message) {
9853
if (!_store) return;
9954
_store.logs += '\n' + message.replace(/\s+$/, '');
@@ -108,8 +63,6 @@ class LogAction {
10863
_store = store;
10964
_ipc = ipc;
11065
_printErrObj = printErrObj;
111-
_FS = FS;
112-
_Share = Share;
11366
_ipc.listen('logs', (event, message) => pushLogs(message));
11467
_ipc.send('logs-ready', null, true);
11568
}

test/unit/action/log.spec.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,13 @@ describe('Action Logs Unit Tests', () => {
99
let sandbox;
1010
let ipc;
1111
let ipcRenderer;
12-
let RNFS;
13-
let Share;
1412

1513
beforeEach(() => {
1614
sandbox = sinon.createSandbox({});
1715
ipcRenderer = {
1816
send: sinon.stub(),
1917
on: sinon.stub().yields('some-event', 'some-arg'),
2018
};
21-
RNFS = {
22-
DocumentDirectoryPath: '/foo/bar',
23-
readFile: sinon.stub().resolves('logs'),
24-
};
25-
Share = {
26-
share: sinon.stub().resolves(true),
27-
};
2819
});
2920

3021
afterEach(() => {
@@ -124,41 +115,5 @@ describe('Action Logs Unit Tests', () => {
124115
expect(store.logs.length, 'to equal', 56);
125116
});
126117
});
127-
128-
describe('getLogPath()', () => {
129-
it('should throw without a FS constructor argument', () => {
130-
expect(() => log.getLogPath(), 'to throw');
131-
});
132-
133-
it('should return a log path with FS constructor argument', () => {
134-
new LogAction(store, ipc, false, RNFS);
135-
expect(log.getLogPath(), 'to be a string');
136-
});
137-
});
138-
139-
describe('getLogs()', () => {
140-
it('should throw without a FS constructor argument', async () => {
141-
await expect(log.getLogs(), 'to be rejected');
142-
});
143-
144-
it('should return logs with an FS constructor argument', async () => {
145-
new LogAction(store, ipc, false, RNFS);
146-
expect(await log.getLogs(), 'to be a string');
147-
expect(RNFS.readFile.called, 'to be true');
148-
});
149-
});
150-
151-
describe('shareLogs()', () => {
152-
it('should resolve false-y without Share or FS constructor arguments', async () => {
153-
expect(await log.shareLogs(), 'not to be ok');
154-
});
155-
156-
it('should share the logs with a Share and FS constructor argument', async () => {
157-
new LogAction(store, ipc, false, RNFS, Share);
158-
expect(await log.shareLogs(), 'to be ok');
159-
expect(RNFS.readFile.called, 'to be true');
160-
expect(Share.share.called, 'to be true');
161-
});
162-
});
163118
});
164119
});

0 commit comments

Comments
 (0)