Make app window thinner fixes #332

This commit is contained in:
akashnimare
2017-12-04 15:19:43 +05:30
parent ce27f92900
commit aa5a47ad53
2 changed files with 44 additions and 44 deletions

View File

@@ -7,63 +7,63 @@ const isDev = require('electron-is-dev');
const browserConsole = console;
const logDir = `${app.getPath('userData')}/Logs`;
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir);
fs.mkdirSync(logDir);
}
function customConsole(opts, type, ...args) {
const { nodeConsole, timestamp } = opts;
if (timestamp) {
args.unshift(timestamp());
}
const { nodeConsole, timestamp } = opts;
if (timestamp) {
args.unshift(timestamp());
}
if (!isDev) {
const nodeConsoleLog = nodeConsole[type] || nodeConsole.log;
nodeConsoleLog.apply(null, args);
}
browserConsole[type].apply(null, args);
if (!isDev) {
const nodeConsoleLog = nodeConsole[type] || nodeConsole.log;
nodeConsoleLog.apply(null, args);
}
browserConsole[type].apply(null, args);
}
function getTimestamp() {
const date = new Date();
const timestamp =
`${date.getMonth()}/${date.getDate()} ` +
`${date.getMinutes()}:${date.getSeconds()}`;
return timestamp;
const date = new Date();
const timestamp =
`${date.getMonth()}/${date.getDate()} ` +
`${date.getMinutes()}:${date.getSeconds()}`;
return timestamp;
}
function setConsoleProto(type) {
Object.defineProperty(this, type, {
value(...args) {
const { timestamp, nodeConsole } = this;
const opts = {
timestamp,
nodeConsole
};
customConsole.apply(null, [].concat(opts, type, args));
}
});
Object.defineProperty(this, type, {
value(...args) {
const { timestamp, nodeConsole } = this;
const opts = {
timestamp,
nodeConsole
};
customConsole.apply(null, [].concat(opts, type, args));
}
});
}
class Console {
constructor(opts = {}) {
let { timestamp, file } = opts;
file = `${logDir}/${file || 'console.log'}`;
if (timestamp === true) {
timestamp = getTimestamp;
}
constructor(opts = {}) {
let { timestamp, file } = opts;
file = `${logDir}/${file || 'console.log'}`;
if (timestamp === true) {
timestamp = getTimestamp;
}
const fileStream = fs.createWriteStream(file);
const nodeConsole = new NodeConsole(fileStream);
this.nodeConsole = nodeConsole;
this.timestamp = timestamp;
this.setUpConsole();
}
const fileStream = fs.createWriteStream(file);
const nodeConsole = new NodeConsole(fileStream);
this.nodeConsole = nodeConsole;
this.timestamp = timestamp;
this.setUpConsole();
}
setUpConsole() {
for (const type in browserConsole) {
setConsoleProto.call(this, type);
}
}
setUpConsole() {
for (const type in browserConsole) {
setConsoleProto.call(this, type);
}
}
}
module.exports = Console;