From 860e2c8c7b8529c0a14ac5c21560b94a6218540e Mon Sep 17 00:00:00 2001 From: DitFranXX Date: Wed, 26 May 2021 13:07:33 +0900 Subject: [PATCH 1/5] feat: :loud_sound: Logger update --- gitadora@asphyxia/handlers/MusicList.ts | 7 +++++-- gitadora@asphyxia/index.ts | 9 +++++---- gitadora@asphyxia/utils/logger.ts | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 gitadora@asphyxia/utils/logger.ts diff --git a/gitadora@asphyxia/handlers/MusicList.ts b/gitadora@asphyxia/handlers/MusicList.ts index 5f46c55..ca3edf0 100644 --- a/gitadora@asphyxia/handlers/MusicList.ts +++ b/gitadora@asphyxia/handlers/MusicList.ts @@ -1,6 +1,9 @@ import { getVersion } from "../utils"; import { defaultProcessRawData, processDataBuilder } from "../data/mdb" import { CommonMusicDataField, readJSONOrXML, readXML } from "../data/mdb"; +import Logger from "../utils/logger" + +const logger = new Logger("MusicList") export const playableMusic: EPR = async (info, data, send) => { const version = getVersion(info); @@ -10,8 +13,8 @@ export const playableMusic: EPR = async (info, data, send) => { music = (await defaultProcessRawData('data/mdb/custom.xml')).music } } catch (e) { - console.error(e.stack); - console.error("Fallback: Using default MDB method.") + logger.error(e.stack); + logger.error("Fallback: Using default MDB method.") music = []; } diff --git a/gitadora@asphyxia/index.ts b/gitadora@asphyxia/index.ts index 7940f4d..9bf221c 100644 --- a/gitadora@asphyxia/index.ts +++ b/gitadora@asphyxia/index.ts @@ -3,6 +3,9 @@ import { playableMusic } from "./handlers/MusicList" import { getPlayer, check, regist, savePlayer } from "./handlers/profiles"; import { updatePlayerInfo } from "./handlers/webui"; import { isAsphyxiaDebugMode, isRequiredCoreVersion } from "./utils"; +import Logger from "./utils/logger"; + +const logger = new Logger("main") export function register() { if(!isRequiredCoreVersion(1, 20)) { @@ -65,9 +68,7 @@ export function register() { R.Unhandled(async (info, data, send) => { if (["eventlog"].includes(info.module)) return; - console.error(`Received Unhandled Response on ${info.method} by ${info.model}/${info.module}`) - if (isAsphyxiaDebugMode()){ - console.error(`Received Request: ${JSON.stringify(data, null, 4)}`) - } + logger.error(`Received Unhandled Response on ${info.method} by ${info.model}/${info.module}`) + logger.debugError(`Received Request: ${JSON.stringify(data, null, 4)}`) }) } \ No newline at end of file diff --git a/gitadora@asphyxia/utils/logger.ts b/gitadora@asphyxia/utils/logger.ts new file mode 100644 index 0000000..94fddb1 --- /dev/null +++ b/gitadora@asphyxia/utils/logger.ts @@ -0,0 +1,25 @@ +import { isAsphyxiaDebugMode } from "."; + +export default class Logger { + public category: string | null; + + public constructor(category?: string) { + this.category = (category == null) ? null : `[${category}]` + } + + public error(...args: any[]) { + this.argsHandler(console.error, ...args) + } + public debugError(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.warn, ...args) + } + } + private argsHandler(target: Function, ...args: any[]) { + if (this.category == null) { + target(...args) + } else { + target(this.category, ...args) + } + } +} \ No newline at end of file From edc6b09a33b45fbaa5c85011359d36f53f743fe4 Mon Sep 17 00:00:00 2001 From: DitFranXX Date: Wed, 26 May 2021 19:52:27 +0900 Subject: [PATCH 2/5] fix: :bug: Trying to fix ex's bg event bug after nt support --- gitadora@asphyxia/handlers/profiles.ts | 19 +++++-------------- gitadora@asphyxia/index.ts | 5 ++++- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/gitadora@asphyxia/handlers/profiles.ts b/gitadora@asphyxia/handlers/profiles.ts index c93ccbd..121549b 100644 --- a/gitadora@asphyxia/handlers/profiles.ts +++ b/gitadora@asphyxia/handlers/profiles.ts @@ -391,20 +391,11 @@ export const getPlayer: EPR = async (info, data, send) => { player: K.ATTR({ 'no': `${no}` }, { now_date: K.ITEM('u64', time), secretmusic: { // TODO: FIX THIS - music: _.merge(_.range(0,2800), _.range(5000, 5100)).map(mid => { - return { - musicid: K.ITEM('s32', mid), - seq: K.ITEM('u16', 255), - kind: K.ITEM('s32', 40), - } - }), - }, - trbitem: { // TODO: FIX THIS - item: _.range(0,750).map(id => { - return { - itemid: K.ITEM('s32', id), - } - }), + music: { + musicid: K.ITEM('s32', 0), + seq: K.ITEM('u16', 255), + kind: K.ITEM('s32', 40), + } }, chara_list: {}, title_parts: {}, diff --git a/gitadora@asphyxia/index.ts b/gitadora@asphyxia/index.ts index 9bf221c..7902cc6 100644 --- a/gitadora@asphyxia/index.ts +++ b/gitadora@asphyxia/index.ts @@ -66,9 +66,12 @@ export function register() { MultiRoute('gametop.get', getPlayer); MultiRoute('gameend.regist', savePlayer); + // Misc + R.Route('bemani_gakuen.get_music_info', true) + R.Unhandled(async (info, data, send) => { if (["eventlog"].includes(info.module)) return; - logger.error(`Received Unhandled Response on ${info.method} by ${info.model}/${info.module}`) + logger.error(`Received Unhandled Request on Method "${info.method}" by ${info.model}/${info.module}`) logger.debugError(`Received Request: ${JSON.stringify(data, null, 4)}`) }) } \ No newline at end of file From f49179a416ca8c0cac1951e170ca633e2af14a1f Mon Sep 17 00:00:00 2001 From: DitFranXX Date: Fri, 28 May 2021 00:51:12 +0900 Subject: [PATCH 3/5] chore: :bookmark: Release GITADORA Plugin v1.1.1 --- gitadora@asphyxia/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gitadora@asphyxia/README.md b/gitadora@asphyxia/README.md index 06b6548..72c32eb 100644 --- a/gitadora@asphyxia/README.md +++ b/gitadora@asphyxia/README.md @@ -1,6 +1,6 @@ GITADORA Plugin for Asphyxia-Core ================================= -![Version: v1.1.0](https://img.shields.io/badge/version-v1.1.0-blue) +![Version: v1.1.1](https://img.shields.io/badge/version-v1.1.1-blue) This plugin is based on converted from public-exported Asphyxia's Routes. @@ -29,8 +29,14 @@ Known Issues Release Notes ============= -v1.1.0 (Current) +v1.1.1 (Current) ---------------- + * fix: Error when create new profile on exchain. + * fix: last song doesn't work correctly. + * misc: Add logger for tracking problem. + +v1.1.0 +------ * NEX+AGE Support (Not full support.) * Restructure bit for maintaining. From 04c84d55f7c0a0cd2fe47293998fc7c6170da5f8 Mon Sep 17 00:00:00 2001 From: DitFranXX Date: Fri, 28 May 2021 00:56:49 +0900 Subject: [PATCH 4/5] feat: :loud_sound: Support logger for more level --- gitadora@asphyxia/utils/logger.ts | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gitadora@asphyxia/utils/logger.ts b/gitadora@asphyxia/utils/logger.ts index 94fddb1..254ff74 100644 --- a/gitadora@asphyxia/utils/logger.ts +++ b/gitadora@asphyxia/utils/logger.ts @@ -7,14 +7,51 @@ export default class Logger { this.category = (category == null) ? null : `[${category}]` } + public error(...args: any[]) { this.argsHandler(console.error, ...args) } + public debugError(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.error, ...args) + } + } + + + public warn(...args: any[]) { + this.argsHandler(console.warn, ...args) + } + + public debugWarn(...args: any[]) { if (isAsphyxiaDebugMode()) { this.argsHandler(console.warn, ...args) } } + + + public info(...args: any[]) { + this.argsHandler(console.info, ...args) + } + + public debugInfo(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.info, ...args) + } + } + + + public log(...args: any[]) { + this.argsHandler(console.log, ...args) + } + + public debugLog(...args: any[]) { + if (isAsphyxiaDebugMode()) { + this.argsHandler(console.log, ...args) + } + } + + private argsHandler(target: Function, ...args: any[]) { if (this.category == null) { target(...args) From 3a8863b452f0c65b2ef1a080744beb19867847ba Mon Sep 17 00:00:00 2001 From: DitFranXX Date: Fri, 28 May 2021 01:00:27 +0900 Subject: [PATCH 5/5] feat: :loud_sound: Update logger on musiclist for more readable. --- gitadora@asphyxia/handlers/MusicList.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitadora@asphyxia/handlers/MusicList.ts b/gitadora@asphyxia/handlers/MusicList.ts index ca3edf0..d33e988 100644 --- a/gitadora@asphyxia/handlers/MusicList.ts +++ b/gitadora@asphyxia/handlers/MusicList.ts @@ -13,8 +13,8 @@ export const playableMusic: EPR = async (info, data, send) => { music = (await defaultProcessRawData('data/mdb/custom.xml')).music } } catch (e) { - logger.error(e.stack); - logger.error("Fallback: Using default MDB method.") + logger.warn("Read Custom MDB failed. Using default MDB as a fallback.") + logger.debugWarn(e.stack); music = []; }