/*
 * CM_LOG.pgc - cm 모듈 서비스 CM_LOG (one service = one file).
 * Split out of the former inline cm_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by cm_svr at tpsvrinit.
 */
#include "CM_LOG.h"

/* 23. CM_LOG - 공통 로그 기록 (cm_log). */
void CM_LOG(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char svc[64], msg[256], bizdate[16];
    long id;
    gets_(b, T_SVCNAME, svc, sizeof(svc)); if (svc[0] == 0) strcpy(svc, "CM");
    gets_(b, T_MSG, msg, sizeof(msg));
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    if (bizdate[0] == 0) { if (cmdb_get_param("BIZ_DATE", bizdate) < 0) strcpy(bizdate, "2026-07-19"); }
    id = cmdb_log(svc, "I", msg, bizdate);
    if (id < 0) FAIL(b);
    setl(b, T_ID1, id);
    OK(b);
}
