diff options
| author | joonhoekim <26rote@gmail.com> | 2025-07-14 12:24:27 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-07-14 12:24:27 +0000 |
| commit | d5d27847a7eded9db59462fa744b76772bc9ce1d (patch) | |
| tree | 55580d7bdfbb48808de7d7bafab65394dabcf500 /lib/soap/mdg/utils.ts | |
| parent | 92403c19aad9a69f342ba135848fc6b75ed3e400 (diff) | |
(김준회) json2xml 로직을 fast-xml-parser로 교체하고 node-soap 미사용, XML 파싱 에러 해결
Diffstat (limited to 'lib/soap/mdg/utils.ts')
| -rw-r--r-- | lib/soap/mdg/utils.ts | 47 |
1 files changed, 47 insertions, 0 deletions
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<T>( 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<void> { + 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 |
