From d5d27847a7eded9db59462fa744b76772bc9ce1d Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Mon, 14 Jul 2025 12:24:27 +0000 Subject: (김준회) json2xml 로직을 fast-xml-parser로 교체하고 node-soap 미사용, XML 파싱 에러 해결 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/soap/mdg/utils.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'lib/soap/mdg/utils.ts') diff --git a/lib/soap/mdg/utils.ts b/lib/soap/mdg/utils.ts index 437988dc..02dd088e 100644 --- a/lib/soap/mdg/utils.ts +++ b/lib/soap/mdg/utils.ts @@ -447,4 +447,51 @@ export async function withSoapLogging( throw error; } +} + +/** + * SOAP 로그 단순 기록 함수 (이미 완료된 작업에 대한 로깅) + * @param direction 수신/송신 구분 + * @param system 시스템명 + * @param interfaceName 인터페이스명 + * @param requestData 요청 XML 데이터 + * @param responseData 응답 XML 데이터 (선택사항) + * @param isSuccess 성공 여부 + * @param errorMessage 에러 메시지 (실패시) + */ +export async function logSoapExecution( + direction: LogDirection, + system: string, + interfaceName: string, + requestData: string, + responseData?: string, + isSuccess: boolean = true, + errorMessage?: string +): Promise { + try { + const logData: SoapLogInsert = { + direction, + system, + interface: interfaceName, + startedAt: new Date(), + endedAt: new Date(), + isSuccess, + requestData, + responseData: responseData || null, + errorMessage: errorMessage || null, + }; + + await db.insert(soapLogs).values(logData); + + console.log(`📝 SOAP 로그 기록 완료 [${direction}] ${system}/${interfaceName} - 성공: ${isSuccess}`); + + // 로그 정리 (백그라운드) + cleanupOldSoapLogs().catch(error => + console.error('백그라운드 로그 정리 실패:', error) + ); + + } catch (error) { + console.error('SOAP 로그 기록 실패:', error); + // 로그 기록 실패는 메인 로직에 영향을 주지 않도록 throw 하지 않음 + } } \ No newline at end of file -- cgit v1.2.3