Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #149 from bookchin/master
Browse files Browse the repository at this point in the history
v3.1.0
  • Loading branch information
aleitner authored May 30, 2017
2 parents 5e8032b + ca0e9d7 commit bf6e3f1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"undef": true,
"unused": true,
"maxparams": 4,
"maxstatements": 15,
"maxstatements": 20,
"maxcomplexity": 6,
"maxdepth": 3,
"maxlen": 80,
Expand Down
9 changes: 9 additions & 0 deletions bin/storjshare-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {Tail} = require('tail');
const colors = require('colors/safe');
const storjshare_logs = require('commander');
const fs = require('fs');
const path = require('path');
const FsLogger = require('fslogger');

storjshare_logs
Expand Down Expand Up @@ -88,6 +89,14 @@ utils.connectToDaemon(config.daemonRpcPort, function(rpc, sock) {
}
}

try {
if (!fs.statSync(logFileDir).isDirectory()) {
logFileDir = path.dirname(logFileDir);
}
} catch (err) {
logFileDir = path.dirname(logFileDir);
}

const fslogger = new FsLogger(logFileDir, storjshare_logs.nodeid);

let currentFile = null;
Expand Down
17 changes: 14 additions & 3 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,20 @@ class RPC {
);
share.readyState = RPC.SHARE_STARTED;

const fslogger = new FsLogger((!share.config.loggerOutputFile) ?
path.join(homedir(),'.config/storjshare/logs') :
share.config.loggerOutputFile, nodeId);
let loggerOutputFile = !share.config.loggerOutputFile
? path.join(homedir(), '.config/storjshare/logs')
: share.config.loggerOutputFile;

try {
if (!fs.statSync(loggerOutputFile).isDirectory()) {
loggerOutputFile = path.dirname(loggerOutputFile);
}
} catch (err) {
loggerOutputFile = path.dirname(loggerOutputFile);
}

const fslogger = new FsLogger(loggerOutputFile, nodeId);

fslogger.setLogLevel(config.logVerbosity);

share.process.stderr.on('data', function(data) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storjshare-daemon",
"version": "3.0.0",
"version": "3.1.0",
"description": "daemon + process manager for sharing space on the storj network",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -72,7 +72,7 @@
"pretty-ms": "^2.1.0",
"rc": "^1.1.6",
"readable-stream": "^2.2.2",
"storj-lib": "^6.4.2",
"storj-lib": "^6.5.0",
"storj-telemetry-reporter": "^5.0.0",
"strip-json-comments": "^2.0.1",
"tail": "^1.2.1"
Expand Down
8 changes: 6 additions & 2 deletions test/api.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ describe('class:RPC', function() {
createWriteStream: sinon.stub().returns(new Writable({
write: (d, e, cb) => cb()
})),
statSync: sinon.stub(),
statSync: sinon.stub().returns({
isDirectory: () => true
}),
readFileSync: sinon.stub().returns(Buffer.from('{}'))
},
'./utils': {
Expand Down Expand Up @@ -212,7 +214,9 @@ describe('class:RPC', function() {
createWriteStream: sinon.stub().returns(new Writable({
write: (d, e, cb) => cb()
})),
statSync: sinon.stub(),
statSync: sinon.stub().returns({
isDirectory: () => false
}),
readFileSync: sinon.stub().returns(Buffer.from('{}'))
},
'./utils': {
Expand Down

0 comments on commit bf6e3f1

Please sign in to comment.