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())
|
||||
|
||||
Reference in New Issue
Block a user