Node.js
[Node] OkPacket 로그 지우기
hazel__
2022. 7. 6. 01:05
오류 상황
42cabi는 pm2로 서버를 구동하고 있다.
pm2 log에 지속적으로 OkPacket 로그가 출력되는 것을 확인했다.
로그인이 완료된 이후, 아래와 같은 로그가 쌓이는 것을 확인하고 이를 지우기위해 고민했다.
오류 원인
OkPacket이 발생하는 원인을 확인했다.
OkPacket은 SQL Query 문을 실행한 뒤에 result를 출력하면 나오는 내용이다.
Node.js MySQL Result Object - Examples
Node.js MySQL Result Object - Examples
Node.js MySQL Result Object When a MySQL Query is executed in Node.js, an object called Result Object is returned to the callback function. The Result Object contains result set or properties that provide information regarding the execution of a query in M
www.tutorialkart.com
Node.js 에서 MySQL Query를 실행하면 MySQL Result Object 가 생성되고, 이는 콜백함수에 담겨있다.
let pool: mariadb.PoolConnection;
const content = `blahblah`;
pool = await con.getConnection();
const result = await pool.query(content);
console.log(result);
query를 실행한 결과인 res를 출력하면 OkPacket이 출력된다.
해결 방법
코드를 확인한 결과,
특정 함수 2곳에서 query의 결과를 콘솔에 출력하고 있었다.
해당 부분을 삭제하여 오류를 수정했다.