Improve logging.
This commit is contained in:
@@ -12,6 +12,7 @@ const DiscordWrapper = require('./assets/js/discordwrapper')
|
||||
const ProcessBuilder = require('./assets/js/processbuilder')
|
||||
const { Util } = require('./assets/js/assetguard')
|
||||
const { RestResponseStatus, isDisplayableError } = require('helios-core/common')
|
||||
const { stdout } = require('process')
|
||||
|
||||
// Launch Elements
|
||||
const launch_content = document.getElementById('launch_content')
|
||||
@@ -22,7 +23,7 @@ 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 = LoggerUtil1('%c[Landing]', 'color: #000668; font-weight: bold')
|
||||
const loggerLanding = LoggerUtil.getLogger('Landing')
|
||||
|
||||
/* Launch Progress Wrapper Functions */
|
||||
|
||||
@@ -86,7 +87,7 @@ function setLaunchEnabled(val){
|
||||
|
||||
// Bind launch button
|
||||
document.getElementById('launch_button').addEventListener('click', function(e){
|
||||
loggerLanding.log('Launching game..')
|
||||
loggerLanding.info('Launching game..')
|
||||
const mcVersion = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer()).getMinecraftVersion()
|
||||
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
||||
if(jExe == null){
|
||||
@@ -99,7 +100,7 @@ document.getElementById('launch_button').addEventListener('click', function(e){
|
||||
|
||||
const jg = new JavaGuard(mcVersion)
|
||||
jg._validateJavaBinary(jExe).then((v) => {
|
||||
loggerLanding.log('Java version meta', v)
|
||||
loggerLanding.info('Java version meta', v)
|
||||
if(v.valid){
|
||||
dlAsync()
|
||||
} else {
|
||||
@@ -160,7 +161,7 @@ server_selection_button.onclick = (e) => {
|
||||
|
||||
// Update Mojang Status Color
|
||||
const refreshMojangStatuses = async function(){
|
||||
loggerLanding.log('Refreshing Mojang Statuses..')
|
||||
loggerLanding.info('Refreshing Mojang Statuses..')
|
||||
|
||||
let status = 'grey'
|
||||
let tooltipEssentialHTML = ''
|
||||
@@ -220,7 +221,7 @@ const refreshMojangStatuses = async function(){
|
||||
}
|
||||
|
||||
const refreshServerStatus = async function(fade = false){
|
||||
loggerLanding.log('Refreshing Server Status')
|
||||
loggerLanding.info('Refreshing Server Status')
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
|
||||
let pLabel = 'SERVER'
|
||||
@@ -295,8 +296,6 @@ function asyncSystemScan(mcVersion, launchAfter = true){
|
||||
toggleLaunchArea(true)
|
||||
setLaunchPercentage(0, 100)
|
||||
|
||||
const loggerSysAEx = LoggerUtil1('%c[SysAEx]', 'color: #353232; font-weight: bold')
|
||||
|
||||
const forkEnv = JSON.parse(JSON.stringify(process.env))
|
||||
forkEnv.CONFIG_DIRECT_PATH = ConfigManager.getLauncherDirectory()
|
||||
|
||||
@@ -311,12 +310,12 @@ function asyncSystemScan(mcVersion, launchAfter = true){
|
||||
// Stdout
|
||||
sysAEx.stdio[1].setEncoding('utf8')
|
||||
sysAEx.stdio[1].on('data', (data) => {
|
||||
loggerSysAEx.log(data)
|
||||
console.log(`\x1b[32m[SysAEx]\x1b[0m ${data}`)
|
||||
})
|
||||
// Stderr
|
||||
sysAEx.stdio[2].setEncoding('utf8')
|
||||
sysAEx.stdio[2].on('data', (data) => {
|
||||
loggerSysAEx.log(data)
|
||||
console.log(`\x1b[31m[SysAEx]\x1b[0m ${data}`)
|
||||
})
|
||||
|
||||
const javaVer = Util.mcVersionAtLeast('1.17', mcVersion) ? '17' : '8'
|
||||
@@ -499,8 +498,7 @@ function dlAsync(login = true){
|
||||
toggleLaunchArea(true)
|
||||
setLaunchPercentage(0, 100)
|
||||
|
||||
const loggerAEx = LoggerUtil1('%c[AEx]', 'color: #353232; font-weight: bold')
|
||||
const loggerLaunchSuite = LoggerUtil1('%c[LaunchSuite]', 'color: #000668; font-weight: bold')
|
||||
const loggerLaunchSuite = LoggerUtil.getLogger('LaunchSuite')
|
||||
|
||||
const forkEnv = JSON.parse(JSON.stringify(process.env))
|
||||
forkEnv.CONFIG_DIRECT_PATH = ConfigManager.getLauncherDirectory()
|
||||
@@ -517,12 +515,12 @@ function dlAsync(login = true){
|
||||
// Stdout
|
||||
aEx.stdio[1].setEncoding('utf8')
|
||||
aEx.stdio[1].on('data', (data) => {
|
||||
loggerAEx.log(data)
|
||||
console.log(`\x1b[32m[AEx]\x1b[0m ${data}`)
|
||||
})
|
||||
// Stderr
|
||||
aEx.stdio[2].setEncoding('utf8')
|
||||
aEx.stdio[2].on('data', (data) => {
|
||||
loggerAEx.log(data)
|
||||
console.log(`\x1b[31m[AEx]\x1b[0m ${data}`)
|
||||
})
|
||||
aEx.on('error', (err) => {
|
||||
loggerLaunchSuite.error('Error during launch', err)
|
||||
@@ -542,27 +540,27 @@ function dlAsync(login = true){
|
||||
switch(m.data){
|
||||
case 'distribution':
|
||||
setLaunchPercentage(20, 100)
|
||||
loggerLaunchSuite.log('Validated distibution index.')
|
||||
loggerLaunchSuite.info('Validated distibution index.')
|
||||
setLaunchDetails('Loading version information..')
|
||||
break
|
||||
case 'version':
|
||||
setLaunchPercentage(40, 100)
|
||||
loggerLaunchSuite.log('Version data loaded.')
|
||||
loggerLaunchSuite.info('Version data loaded.')
|
||||
setLaunchDetails('Validating asset integrity..')
|
||||
break
|
||||
case 'assets':
|
||||
setLaunchPercentage(60, 100)
|
||||
loggerLaunchSuite.log('Asset Validation Complete')
|
||||
loggerLaunchSuite.info('Asset Validation Complete')
|
||||
setLaunchDetails('Validating library integrity..')
|
||||
break
|
||||
case 'libraries':
|
||||
setLaunchPercentage(80, 100)
|
||||
loggerLaunchSuite.log('Library validation complete.')
|
||||
loggerLaunchSuite.info('Library validation complete.')
|
||||
setLaunchDetails('Validating miscellaneous file integrity..')
|
||||
break
|
||||
case 'files':
|
||||
setLaunchPercentage(100, 100)
|
||||
loggerLaunchSuite.log('File validation complete.')
|
||||
loggerLaunchSuite.info('File validation complete.')
|
||||
setLaunchDetails('Downloading files..')
|
||||
break
|
||||
}
|
||||
@@ -650,7 +648,7 @@ function dlAsync(login = true){
|
||||
|
||||
if(login && allGood) {
|
||||
const authUser = ConfigManager.getSelectedAccount()
|
||||
loggerLaunchSuite.log(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
|
||||
loggerLaunchSuite.info(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
|
||||
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion())
|
||||
setLaunchDetails('Launching game..')
|
||||
|
||||
@@ -717,7 +715,7 @@ function dlAsync(login = true){
|
||||
DiscordWrapper.initRPC(distro.discord, serv.discord)
|
||||
hasRPC = true
|
||||
proc.on('close', (code, signal) => {
|
||||
loggerLaunchSuite.log('Shutting down Discord Rich Presence..')
|
||||
loggerLaunchSuite.info('Shutting down Discord Rich Presence..')
|
||||
DiscordWrapper.shutdownRPC()
|
||||
hasRPC = false
|
||||
proc = null
|
||||
@@ -748,7 +746,7 @@ function dlAsync(login = true){
|
||||
serv = data.getServer(ConfigManager.getSelectedServer())
|
||||
aEx.send({task: 'execute', function: 'validateEverything', argsArr: [ConfigManager.getSelectedServer(), DistroManager.isDevMode()]})
|
||||
}, (err) => {
|
||||
loggerLaunchSuite.log('Error while fetching a fresh copy of the distribution index.', err)
|
||||
loggerLaunchSuite.info('Error while fetching a fresh copy of the distribution index.', err)
|
||||
refreshDistributionIndex(false, (data) => {
|
||||
onDistroRefresh(data)
|
||||
serv = data.getServer(ConfigManager.getSelectedServer())
|
||||
|
||||
@@ -21,8 +21,6 @@ const loginForm = document.getElementById('loginForm')
|
||||
// Control variables.
|
||||
let lu = false, lp = false
|
||||
|
||||
const loggerLogin = LoggerUtil1('%c[Login]', 'color: #000668; font-weight: bold')
|
||||
|
||||
|
||||
/**
|
||||
* Show a login error.
|
||||
|
||||
@@ -60,7 +60,7 @@ function getCurrentView(){
|
||||
function showMainUI(data){
|
||||
|
||||
if(!isDev){
|
||||
loggerAutoUpdater.log('Initializing..')
|
||||
loggerAutoUpdater.info('Initializing..')
|
||||
ipcRenderer.send('autoUpdateAction', 'initAutoUpdater', ConfigManager.getAllowPrerelease())
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,9 @@ const {ipcRenderer, shell, webFrame} = require('electron')
|
||||
const remote = require('@electron/remote')
|
||||
const isDev = require('./assets/js/isdev')
|
||||
const { LoggerUtil } = require('helios-core')
|
||||
const LoggerUtil1 = require('./assets/js/loggerutil')
|
||||
|
||||
const loggerUICore = LoggerUtil1('%c[UICore]', 'color: #000668; font-weight: bold')
|
||||
const loggerAutoUpdater = LoggerUtil1('%c[AutoUpdater]', 'color: #000668; font-weight: bold')
|
||||
const loggerAutoUpdaterSuccess = LoggerUtil1('%c[AutoUpdater]', 'color: #209b07; font-weight: bold')
|
||||
const loggerUICore = LoggerUtil.getLogger('UICore')
|
||||
const loggerAutoUpdater = LoggerUtil.getLogger('AutoUpdater')
|
||||
|
||||
// Log deprecation and process warnings.
|
||||
process.traceProcessWarnings = true
|
||||
@@ -43,11 +41,11 @@ if(!isDev){
|
||||
ipcRenderer.on('autoUpdateNotification', (event, arg, info) => {
|
||||
switch(arg){
|
||||
case 'checking-for-update':
|
||||
loggerAutoUpdater.log('Checking for update..')
|
||||
loggerAutoUpdater.info('Checking for update..')
|
||||
settingsUpdateButtonStatus('Checking for Updates..', true)
|
||||
break
|
||||
case 'update-available':
|
||||
loggerAutoUpdaterSuccess.log('New update available', info.version)
|
||||
loggerAutoUpdater.info('New update available', info.version)
|
||||
|
||||
if(process.platform === 'darwin'){
|
||||
info.darwindownload = `https://github.com/dscalzi/HeliosLauncher/releases/download/v${info.version}/Helios-Launcher-setup-${info.version}${process.arch === 'arm64' ? '-arm64' : '-x64'}.dmg`
|
||||
@@ -57,7 +55,7 @@ if(!isDev){
|
||||
populateSettingsUpdateInformation(info)
|
||||
break
|
||||
case 'update-downloaded':
|
||||
loggerAutoUpdaterSuccess.log('Update ' + info.version + ' ready to be installed.')
|
||||
loggerAutoUpdater.info('Update ' + info.version + ' ready to be installed.')
|
||||
settingsUpdateButtonStatus('Install Now', false, () => {
|
||||
if(!isDev){
|
||||
ipcRenderer.send('autoUpdateAction', 'installUpdateNow')
|
||||
@@ -66,7 +64,7 @@ if(!isDev){
|
||||
showUpdateUI(info)
|
||||
break
|
||||
case 'update-not-available':
|
||||
loggerAutoUpdater.log('No new update found.')
|
||||
loggerAutoUpdater.info('No new update found.')
|
||||
settingsUpdateButtonStatus('Check for Updates')
|
||||
break
|
||||
case 'ready':
|
||||
@@ -78,9 +76,9 @@ if(!isDev){
|
||||
case 'realerror':
|
||||
if(info != null && info.code != null){
|
||||
if(info.code === 'ERR_UPDATER_INVALID_RELEASE_FEED'){
|
||||
loggerAutoUpdater.log('No suitable releases found.')
|
||||
loggerAutoUpdater.info('No suitable releases found.')
|
||||
} else if(info.code === 'ERR_XML_MISSED_ELEMENT'){
|
||||
loggerAutoUpdater.log('No releases found.')
|
||||
loggerAutoUpdater.info('No releases found.')
|
||||
} else {
|
||||
loggerAutoUpdater.error('Error during update check..', info)
|
||||
loggerAutoUpdater.debug('Error Code:', info.code)
|
||||
@@ -88,7 +86,7 @@ if(!isDev){
|
||||
}
|
||||
break
|
||||
default:
|
||||
loggerAutoUpdater.log('Unknown argument', arg)
|
||||
loggerAutoUpdater.info('Unknown argument', arg)
|
||||
break
|
||||
}
|
||||
})
|
||||
@@ -131,12 +129,12 @@ function showUpdateUI(info){
|
||||
|
||||
/* jQuery Example
|
||||
$(function(){
|
||||
loggerUICore.log('UICore Initialized');
|
||||
loggerUICore.info('UICore Initialized');
|
||||
})*/
|
||||
|
||||
document.addEventListener('readystatechange', function () {
|
||||
if (document.readyState === 'interactive'){
|
||||
loggerUICore.log('UICore Initializing..')
|
||||
loggerUICore.info('UICore Initializing..')
|
||||
|
||||
// Bind close button.
|
||||
Array.from(document.getElementsByClassName('fCb')).map((val) => {
|
||||
|
||||
Reference in New Issue
Block a user