Wrap calls to console.log through LoggerUtil (prefixes).

This commit is contained in:
Daniel Scalzi 2018-08-22 14:21:49 -04:00
parent 37606dc8d2
commit 0346597afe
No known key found for this signature in database
GPG Key ID: 5CA2F145B63535F9
12 changed files with 151 additions and 103 deletions

View File

@ -10,7 +10,10 @@
*/
// Requirements
const ConfigManager = require('./configmanager')
const LoggerUtil = require('./loggerutil')
const Mojang = require('./mojang')
const logger = LoggerUtil('%c[AuthManager]', 'color: #a02d2a; font-weight: bold')
const loggerSuccess = LoggerUtil('%c[AuthManager]', 'color: #209b07; font-weight: bold')
// Functions
@ -69,18 +72,20 @@ exports.validateSelected = async function(){
if(!isValid){
try {
const session = await Mojang.refresh(current.accessToken, ConfigManager.getClientToken())
console.log('ses', session)
ConfigManager.updateAuthAccount(current.uuid, session.accessToken)
ConfigManager.save()
} catch(err) {
console.debug('Error while validating selected profile:', err)
logger.debug('Error while validating selected profile:', err)
if(err && err.error === 'ForbiddenOperationException'){
// What do we do?
}
logger.log('Account access token is invalid.')
return false
}
loggerSuccess.log('Account access token validated.')
return true
} else {
loggerSuccess.log('Account access token validated.')
return true
}
}

View File

@ -1,9 +1,11 @@
const fs = require('fs')
const fs = require('fs')
const mkpath = require('mkdirp')
const os = require('os')
const path = require('path')
const os = require('os')
const path = require('path')
const uuidV4 = require('uuid/v4')
const logger = require('./loggerutil')('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold')
const sysRoot = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME)
const dataPath = path.join(sysRoot, '.westeroscraft')
@ -106,9 +108,9 @@ exports.load = function(){
config = JSON.parse(fs.readFileSync(filePath, 'UTF-8'))
doValidate = true
} catch (err){
console.error(err)
console.log('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold', 'Configuration file contains malformed JSON or is corrupt.')
console.log('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold', 'Generating a new configuration file.')
logger.error(err)
logger.log('Configuration file contains malformed JSON or is corrupt.')
logger.log('Generating a new configuration file.')
mkpath.sync(path.join(filePath, '..'))
config = DEFAULT_CONFIG
exports.save()
@ -118,7 +120,7 @@ exports.load = function(){
exports.save()
}
}
console.log('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold', 'Successfully Loaded')
logger.log('Successfully Loaded')
}
/**

View File

@ -1,4 +1,6 @@
// Work in progress
const logger = require('./loggerutil')('%c[DiscordWrapper]', 'color: #7289da; font-weight: bold')
const {Client} = require('discord-rpc')
let client
@ -19,15 +21,15 @@ exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting
}
client.on('ready', () => {
console.log('%c[Discord Wrapper]', 'color: #a02d2a; font-weight: bold', 'Discord RPC Connected')
logger.log('Discord RPC Connected')
client.setActivity(activity)
})
client.login({clientId: genSettings.clientId}).catch(error => {
if(error.message.includes('ENOENT')) {
console.log('%c[Discord Wrapper]', 'color: #a02d2a; font-weight: bold', 'Unable to initialize Discord Rich Presence, no client detected.')
logger.log('Unable to initialize Discord Rich Presence, no client detected.')
} else {
console.log('%c[Discord Wrapper]', 'color: #a02d2a; font-weight: bold', 'Unable to initialize Discord Rich Presence: ' + error.message, error)
logger.log('Unable to initialize Discord Rich Presence: ' + error.message, error)
}
})
}

View File

@ -3,6 +3,7 @@ const path = require('path')
const request = require('request')
const ConfigManager = require('./configmanager')
const logger = require('./loggerutil')('%c[DistroManager]', 'color: #a02d2a; font-weight: bold')
/**
* Represents the download information
@ -168,7 +169,7 @@ class Module {
} catch (err) {
// Improper identifier
console.error('Improper ID for module', this.identifier, err)
logger.error('Improper ID for module', this.identifier, err)
}
}
@ -567,10 +568,10 @@ exports.pullLocal = function(){
exports.setDevMode = function(value){
if(value){
console.log('%c[DistroManager]', 'color: #a02d2a; font-weight: bold', 'Developer mode enabled.')
console.log('%c[DistroManager]', 'color: #a02d2a; font-weight: bold', 'If you don\'t know what that means, revert immediately.')
logger.log('Developer mode enabled.')
logger.log('If you don\'t know what that means, revert immediately.')
} else {
console.log('%c[DistroManager]', 'color: #a02d2a; font-weight: bold', 'Developer mode disabled.')
logger.log('Developer mode disabled.')
}
DEV_MODE = value
}
@ -585,10 +586,3 @@ exports.isDevMode = function(){
exports.getDistribution = function(){
return data
}
/*async function debug(){
const d = await exports.pullRemote()
console.log(d)
}
debug()*/
//console.log(DistroIndex.fromJSON(JSON.parse(require('fs').readFileSync('../distribution.json', 'utf-8'))))

View File

@ -0,0 +1,28 @@
class LoggerUtil {
constructor(prefix, style){
this.prefix = prefix
this.style = style
}
log(){
console.log.apply(null, [this.prefix, this.style, ...arguments])
}
info(){
console.info.apply(null, [this.prefix, this.style, ...arguments])
}
debug(){
console.debug.apply(null, [this.prefix, this.style, ...arguments])
}
error(){
console.error.apply(null, [this.prefix, this.style, ...arguments])
}
}
module.exports = function (prefix, style){
return new LoggerUtil(prefix, style)
}

View File

@ -7,6 +7,7 @@
*/
// Requirements
const request = require('request')
const logger = require('./loggerutil')('%c[Mojang]', 'color: #a02d2a; font-weight: bold')
// Constants
const minecraftAgent = {
@ -95,8 +96,8 @@ exports.status = function(){
function(error, response, body){
if(error || response.statusCode !== 200){
console.warn('Unable to retrieve Mojang status.')
console.debug('Error while retrieving Mojang statuses:', error)
logger.warn('Unable to retrieve Mojang status.')
logger.debug('Error while retrieving Mojang statuses:', error)
//reject(error || response.statusCode)
for(let i=0; i<statuses.length; i++){
statuses[i].status = 'grey'
@ -145,7 +146,7 @@ exports.authenticate = function(username, password, clientToken, requestUser = t
},
function(error, response, body){
if(error){
console.error('Error during authentication.', error)
logger.error('Error during authentication.', error)
reject(error)
} else {
if(response.statusCode === 200){
@ -179,7 +180,7 @@ exports.validate = function(accessToken, clientToken){
},
function(error, response, body){
if(error){
console.error('Error during validation.', error)
logger.error('Error during validation.', error)
reject(error)
} else {
if(response.statusCode === 403){
@ -214,7 +215,7 @@ exports.invalidate = function(accessToken, clientToken){
},
function(error, response, body){
if(error){
console.error('Error during invalidation.', error)
logger.error('Error during invalidation.', error)
reject(error)
} else {
if(response.statusCode === 204){
@ -251,7 +252,7 @@ exports.refresh = function(accessToken, clientToken, requestUser = true){
},
function(error, response, body){
if(error){
console.error('Error during refresh.', error)
logger.error('Error during refresh.', error)
reject(error)
} else {
if(response.statusCode === 200){

View File

@ -1,12 +1,13 @@
const {ipcRenderer} = require('electron')
const os = require('os')
const path = require('path')
const rimraf = require('rimraf')
const os = require('os')
const path = require('path')
const rimraf = require('rimraf')
const ConfigManager = require('./configmanager')
const DistroManager = require('./distromanager')
const logger = require('./loggerutil')('%c[Preloader]', 'color: #a02d2a; font-weight: bold')
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Loading..')
logger.log('Loading..')
// Load ConfigManager
ConfigManager.load()
@ -16,7 +17,7 @@ function onDistroLoad(data){
// Resolve the selected server if its value has yet to be set.
if(ConfigManager.getSelectedServer() == null || data.getServer(ConfigManager.getSelectedServer()) == null){
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Determining default selected server..')
logger.log('Determining default selected server..')
ConfigManager.setSelectedServer(data.getMainServer().getID())
ConfigManager.save()
}
@ -26,27 +27,27 @@ function onDistroLoad(data){
// Ensure Distribution is downloaded and cached.
DistroManager.pullRemote().then((data) => {
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Loaded distribution index.')
logger.log('Loaded distribution index.')
onDistroLoad(data)
}).catch((err) => {
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Failed to load distribution index.')
console.error(err)
logger.log('Failed to load distribution index.')
logger.error(err)
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Attempting to load an older version of the distribution index.')
logger.log('Attempting to load an older version of the distribution index.')
// Try getting a local copy, better than nothing.
DistroManager.pullLocal().then((data) => {
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Successfully loaded an older version of the distribution index.')
logger.log('Successfully loaded an older version of the distribution index.')
onDistroLoad(data)
}).catch((err) => {
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Failed to load an older version of the distribution index.')
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Application cannot run.')
console.error(err)
logger.log('Failed to load an older version of the distribution index.')
logger.log('Application cannot run.')
logger.error(err)
onDistroLoad(null)
@ -57,8 +58,8 @@ DistroManager.pullRemote().then((data) => {
// Clean up temp dir incase previous launches ended unexpectedly.
rimraf(path.join(os.tmpdir(), ConfigManager.getTempNativeFolder()), (err) => {
if(err){
console.warn('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Error while cleaning natives directory', err)
logger.warn('Error while cleaning natives directory', err)
} else {
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Cleaned natives directory.')
logger.log('Cleaned natives directory.')
}
})

View File

@ -8,9 +8,12 @@ const path = require('path')
const rimraf = require('rimraf')
const {URL} = require('url')
const { Library } = require('./assetguard')
const { Library } = require('./assetguard')
const ConfigManager = require('./configmanager')
const DistroManager = require('./distromanager')
const LoggerUtil = require('./loggerutil')
const logger = LoggerUtil('%c[ProcessBuilder]', 'color: #003996; font-weight: bold')
class ProcessBuilder {
@ -37,7 +40,7 @@ class ProcessBuilder {
const tempNativePath = path.join(os.tmpdir(), ConfigManager.getTempNativeFolder(), crypto.pseudoRandomBytes(16).toString('hex'))
process.throwDeprecation = true
this.setupLiteLoader()
console.log('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Using liteloader:', this.usingLiteLoader)
logger.log('Using liteloader:', this.usingLiteLoader)
const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.getID()).mods, this.server.getModules())
this.constructModList('forge', modObj.fMods, true)
if(this.usingLiteLoader){
@ -46,7 +49,7 @@ class ProcessBuilder {
const uberModArr = modObj.fMods.concat(modObj.lMods)
const args = this.constructJVMArguments(uberModArr, tempNativePath)
console.log(args)
logger.log('Launch Arguments:', args)
const child = child_process.spawn(ConfigManager.getJavaExecutable(), args, {
cwd: this.gameDir,
@ -60,19 +63,22 @@ class ProcessBuilder {
child.stdout.setEncoding('utf8')
child.stderr.setEncoding('utf8')
const loggerMCstdout = LoggerUtil('%c[Minecraft]', 'color: #36b030; font-weight: bold')
const loggerMCstderr = LoggerUtil('%c[Minecraft]', 'color: #b03030; font-weight: bold')
child.stdout.on('data', (data) => {
console.log('%c[Minecraft]', 'color: #36b030; font-weight: bold', data)
loggerMCstdout.log(data)
})
child.stderr.on('data', (data) => {
console.log('%c[Minecraft]', 'color: #b03030; font-weight: bold', data)
loggerMCstderr.log(data)
})
child.on('close', (code, signal) => {
console.log('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Exited with code', code)
logger.log('Exited with code', code)
rimraf(tempNativePath, (err) => {
if(err){
console.warn('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Error while deleting temp dir', err)
logger.warn('Error while deleting temp dir', err)
} else {
console.log('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Temp dir deleted successfully.')
logger.log('Temp dir deleted successfully.')
}
})
})
@ -401,7 +407,7 @@ class ProcessBuilder {
if(!shouldExclude){
fs.writeFile(path.join(tempNativePath, fileName), zipEntries[i].getData(), (err) => {
if(err){
console.error('Error while extracting native library:', err)
logger.error('Error while extracting native library:', err)
}
})
}

View File

@ -21,6 +21,8 @@ const launch_details_text = document.getElementById('launch_details_text')
const server_selection_button = document.getElementById('server_selection_button')
const user_text = document.getElementById('user_text')
const loggerLanding = LoggerUtil('%c[Landing]', 'color: #000668; font-weight: bold')
/* Launch Progress Wrapper Functions */
/**
@ -83,7 +85,7 @@ function setLaunchEnabled(val){
// Bind launch button
document.getElementById('launch_button').addEventListener('click', function(e){
console.log('Launching game..')
loggerLanding.log('Launching game..')
const jExe = ConfigManager.getJavaExecutable()
if(jExe == null){
asyncSystemScan()
@ -94,7 +96,7 @@ document.getElementById('launch_button').addEventListener('click', function(e){
setLaunchPercentage(0, 100)
AssetGuard._validateJavaBinary(jExe).then((v) => {
console.log(v)
loggerLanding.log('Java version meta', v)
if(v.valid){
dlAsync()
} else {
@ -152,7 +154,7 @@ server_selection_button.onclick = (e) => {
// Update Mojang Status Color
const refreshMojangStatuses = async function(){
console.log('Refreshing Mojang Statuses..')
loggerLanding.log('Refreshing Mojang Statuses..')
let status = 'grey'
let tooltipEssentialHTML = ''
@ -200,8 +202,8 @@ const refreshMojangStatuses = async function(){
}
} catch (err) {
console.warn('Unable to refresh Mojang service status.')
console.debug(err)
loggerLanding.warn('Unable to refresh Mojang service status.')
loggerLanding.debug(err)
}
document.getElementById('mojangStatusEssentialContainer').innerHTML = tooltipEssentialHTML
@ -210,7 +212,7 @@ const refreshMojangStatuses = async function(){
}
const refreshServerStatus = async function(fade = false){
console.log('Refreshing Server Status')
loggerLanding.log('Refreshing Server Status')
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
let pLabel = 'SERVER'
@ -225,8 +227,8 @@ const refreshServerStatus = async function(fade = false){
}
} catch (err) {
console.warn('Unable to refresh server status, assuming offline.')
console.debug(err)
loggerLanding.warn('Unable to refresh server status, assuming offline.')
loggerLanding.debug(err)
}
if(fade){
$('#server_status_wrapper').fadeOut(250, () => {
@ -261,6 +263,8 @@ function asyncSystemScan(launchAfter = true){
toggleLaunchArea(true)
setLaunchPercentage(0, 100)
const loggerSysAEx = LoggerUtil('%c[SysAEx]', 'color: #353232; font-weight: bold')
// Fork a process to run validations.
sysAEx = cp.fork(path.join(__dirname, 'assets', 'js', 'assetexec.js'), [
ConfigManager.getCommonDirectory(),
@ -269,12 +273,14 @@ function asyncSystemScan(launchAfter = true){
stdio: 'pipe'
})
// Stdout
sysAEx.stdio[1].setEncoding('utf8')
sysAEx.stdio[1].on('data', (data) => {
console.log('%c[SysAEx]', 'color: #353232; font-weight: bold', data.toString('utf-8'))
loggerSysAEx.log(data)
})
// Stderr
sysAEx.stdio[2].setEncoding('utf8')
sysAEx.stdio[2].on('data', (data) => {
console.log('%c[SysAEx]', 'color: #353232; font-weight: bold', data.toString('utf-8'))
loggerSysAEx.log(data)
})
sysAEx.on('message', (m) => {
@ -442,8 +448,7 @@ function dlAsync(login = true){
if(login) {
if(ConfigManager.getSelectedAccount() == null){
console.error('login first.')
//in devtools AuthManager.addAccount(username, pass)
loggerLanding.error('You must be logged into an account.')
return
}
}
@ -452,6 +457,9 @@ function dlAsync(login = true){
toggleLaunchArea(true)
setLaunchPercentage(0, 100)
const loggerAEx = LoggerUtil('%c[AEx]', 'color: #353232; font-weight: bold')
const loggerLaunchSuite = LoggerUtil('%c[LaunchSuite]', 'color: #000668; font-weight: bold')
// Start AssetExec to run validations and downloads in a forked process.
aEx = cp.fork(path.join(__dirname, 'assets', 'js', 'assetexec.js'), [
ConfigManager.getCommonDirectory(),
@ -460,12 +468,14 @@ function dlAsync(login = true){
stdio: 'pipe'
})
// Stdout
aEx.stdio[1].setEncoding('utf8')
aEx.stdio[1].on('data', (data) => {
console.log('%c[AEx]', 'color: #353232; font-weight: bold', data.toString('utf-8'))
loggerAEx.log(data)
})
// Stderr
aEx.stdio[2].setEncoding('utf8')
aEx.stdio[2].on('data', (data) => {
console.log('%c[AEx]', 'color: #353232; font-weight: bold', data.toString('utf-8'))
loggerAEx.log(data)
})
// Establish communications between the AssetExec and current process.
@ -475,27 +485,27 @@ function dlAsync(login = true){
switch(m.data){
case 'distribution':
setLaunchPercentage(20, 100)
console.log('Validated distibution index.')
loggerLaunchSuite.log('Validated distibution index.')
setLaunchDetails('Loading version information..')
break
case 'version':
setLaunchPercentage(40, 100)
console.log('Version data loaded.')
loggerLaunchSuite.log('Version data loaded.')
setLaunchDetails('Validating asset integrity..')
break
case 'assets':
setLaunchPercentage(60, 100)
console.log('Asset Validation Complete')
loggerLaunchSuite.log('Asset Validation Complete')
setLaunchDetails('Validating library integrity..')
break
case 'libraries':
setLaunchPercentage(80, 100)
console.log('Library validation complete.')
loggerLaunchSuite.log('Library validation complete.')
setLaunchDetails('Validating miscellaneous file integrity..')
break
case 'files':
setLaunchPercentage(100, 100)
console.log('File validation complete.')
loggerLaunchSuite.log('File validation complete.')
setLaunchDetails('Downloading files..')
break
}
@ -544,7 +554,7 @@ function dlAsync(login = true){
} else if(m.context === 'error'){
switch(m.data){
case 'download':
console.error(m.error)
loggerLaunchSuite.error('Error while downloading:', m.error)
if(m.error.code === 'ENOENT'){
setOverlayContent(
@ -574,7 +584,7 @@ function dlAsync(login = true){
// If these properties are not defined it's likely an error.
if(m.result.forgeData == null || m.result.versionData == null){
console.error(m.result)
loggerLaunchSuite.error('Error during validation:', m.result)
}
forgeData = m.result.forgeData
@ -582,7 +592,7 @@ function dlAsync(login = true){
if(login) {
const authUser = ConfigManager.getSelectedAccount()
console.log('authu', authUser)
loggerLaunchSuite.log(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser)
setLaunchDetails('Launching game..')
@ -615,7 +625,7 @@ function dlAsync(login = true){
const gameErrorListener = function(data){
data = data.trim()
if(data.indexOf('Could not find or load main class net.minecraft.launchwrapper.Launch') > -1){
console.error('Game launch failed, LaunchWrapper was not downloaded properly.')
loggerLaunchSuite.error('Game launch failed, LaunchWrapper was not downloaded properly.')
setOverlayContent(
'Error During Launch',
'The main file, LaunchWrapper, failed to download properly. As a result, the game cannot launch.<br><br>To fix this issue, temporarily turn off your antivirus software and launch the game again.<br><br>If you have time, please <a href="https://github.com/WesterosCraftCode/ElectronLauncher/issues">submit an issue</a> and let us know what antivirus software you use. We\'ll contact them and try to straighten things out.',
@ -643,7 +653,7 @@ function dlAsync(login = true){
DiscordWrapper.initRPC(distro.discord, serv.discord)
hasRPC = true
proc.on('close', (code, signal) => {
console.log('Shutting down Discord Rich Presence..')
loggerLaunchSuite.log('Shutting down Discord Rich Presence..')
DiscordWrapper.shutdownRPC()
hasRPC = false
proc = null
@ -652,7 +662,7 @@ function dlAsync(login = true){
} catch(err) {
console.error('Error during launch', err)
loggerLaunchSuite.error('Error during launch', err)
setOverlayContent(
'Error During Launch',
'Please check the console for more details.',
@ -681,13 +691,13 @@ function dlAsync(login = true){
serv = data.getServer(ConfigManager.getSelectedServer())
aEx.send({task: 'execute', function: 'validateEverything', argsArr: [ConfigManager.getSelectedServer(), DistroManager.isDevMode()]})
}, (err) => {
console.log(err)
loggerLaunchSuite.log('Error while fetching a fresh copy of the distribution index.', err)
refreshDistributionIndex(false, (data) => {
onDistroRefresh(data)
serv = data.getServer(ConfigManager.getSelectedServer())
aEx.send({task: 'execute', function: 'validateEverything', argsArr: [ConfigManager.getSelectedServer(), DistroManager.isDevMode()]})
}, (err) => {
console.error('Unable to refresh distribution index.', err)
loggerLaunchSuite.error('Unable to refresh distribution index.', err)
if(DistroManager.getDistribution() == null){
setOverlayContent(
'Fatal Error',

View File

@ -21,6 +21,8 @@ const loginForm = document.getElementById('loginForm')
// Control variables.
let lu = false, lp = false
const loggerLogin = LoggerUtil('%c[Login]', 'color: #000668; font-weight: bold')
/**
* Show a login error.
@ -256,7 +258,6 @@ loginButton.addEventListener('click', () => {
loginButton.innerHTML = loginButton.innerHTML.replace('LOGGING IN', 'SUCCESS')
$('.circle-loader').toggleClass('load-complete')
$('.checkmark').toggle()
//console.log(value)
setTimeout(() => {
switchView(VIEWS.login, loginViewOnSuccess, 500, 500, () => {
// Temporary workaround
@ -284,7 +285,7 @@ loginButton.addEventListener('click', () => {
toggleOverlay(false)
})
toggleOverlay(true)
console.log(err)
loggerLogin.log('Error while logging in.', err)
})
})

View File

@ -57,7 +57,7 @@ function getCurrentView(){
function showMainUI(data){
if(!isDev){
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'Initializing..')
loggerAutoUpdater.log('Initializing..')
ipcRenderer.send('autoUpdateAction', 'initAutoUpdater', ConfigManager.getAllowPrerelease())
}
@ -73,13 +73,7 @@ function showMainUI(data){
// If this is enabled in a development environment we'll get ratelimited.
// The relaunch frequency is usually far too high.
if(!isDev && isLoggedIn){
validateSelectedAccount().then((v) => {
if(v){
console.log('%c[AuthManager]', 'color: #209b07; font-weight: bold', 'Account access token validated.')
} else {
console.log('%c[AuthManager]', 'color: #a02d2a; font-weight: bold', 'Account access token is invalid.')
}
})
validateSelectedAccount()
}
if(ConfigManager.isFirstLaunch()){

View File

@ -8,6 +8,11 @@
const $ = require('jquery')
const {ipcRenderer, remote, shell, webFrame} = require('electron')
const isDev = require('electron-is-dev')
const LoggerUtil = require('./assets/js/loggerutil')
const loggerUICore = LoggerUtil('%c[UICore]', 'color: #000668; font-weight: bold')
const loggerAutoUpdater = LoggerUtil('%c[AutoUpdater]', 'color: #000668; font-weight: bold')
const loggerAutoUpdaterSuccess = LoggerUtil('%c[AutoUpdater]', 'color: #209b07; font-weight: bold')
// Disable eval function.
// eslint-disable-next-line
@ -33,15 +38,15 @@ if(!isDev){
ipcRenderer.on('autoUpdateNotification', (event, arg, info) => {
switch(arg){
case 'checking-for-update':
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'Checking for update..')
loggerAutoUpdater.log('Checking for update..')
settingsUpdateButtonStatus('Checking for Updates..', true)
break
case 'update-available':
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'New update available', info.version)
loggerAutoUpdaterSuccess.log('New update available', info.version)
populateSettingsUpdateInformation(info)
break
case 'update-downloaded':
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'Update ' + info.version + ' ready to be installed.')
loggerAutoUpdaterSuccess.log('Update ' + info.version + ' ready to be installed.')
settingsUpdateButtonStatus('Install Now', false, () => {
if(!isDev){
ipcRenderer.send('autoUpdateAction', 'installUpdateNow')
@ -50,7 +55,7 @@ if(!isDev){
showUpdateUI(info)
break
case 'update-not-available':
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'No new update found.')
loggerAutoUpdater.log('No new update found.')
settingsUpdateButtonStatus('Check for Updates')
break
case 'ready':
@ -62,17 +67,17 @@ if(!isDev){
case 'realerror':
if(info != null && info.code != null){
if(info.code === 'ERR_UPDATER_INVALID_RELEASE_FEED'){
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'No suitable releases found.')
loggerAutoUpdater.log('No suitable releases found.')
} else if(info.code === 'ERR_XML_MISSED_ELEMENT'){
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'No releases found.')
loggerAutoUpdater.log('No releases found.')
} else {
console.error('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'Error during update check..', info)
console.debug('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'Error Code:', info.code)
loggerAutoUpdater.error('Error during update check..', info)
loggerAutoUpdater.debug('Error Code:', info.code)
}
}
break
default:
console.log('%c[AutoUpdater]', 'color: #a02d2a; font-weight: bold', 'Unknown argument', arg)
loggerAutoUpdater.log('Unknown argument', arg)
break
}
})
@ -115,12 +120,12 @@ function showUpdateUI(info){
/* jQuery Example
$(function(){
console.log('UICore Initialized');
loggerUICore.log('UICore Initialized');
})*/
document.addEventListener('readystatechange', function () {
if (document.readyState === 'interactive'){
console.log('UICore Initializing..')
loggerUICore.log('UICore Initializing..')
// Bind close button.
Array.from(document.getElementsByClassName('fCb')).map((val) => {
@ -183,7 +188,6 @@ document.addEventListener('readystatechange', function () {
*/
$(document).on('click', 'a[href^="http"]', function(event) {
event.preventDefault()
//console.log(os.homedir())
shell.openExternal(this.href)
})