Update socket_io_provider.ts

This commit is contained in:
nguyentrungthat 2026-03-30 08:31:41 +07:00
parent fa8fd8116f
commit d2263a3ec3
1 changed files with 14 additions and 2 deletions

View File

@ -310,10 +310,22 @@ export class WebSocketIo {
}) })
socket.on('get_list_logs', async (data) => { socket.on('get_list_logs', async (data) => {
const dir = 'storage/system_logs'
let getListSystemLogs = fs let getListSystemLogs = fs
.readdirSync('storage/system_logs') .readdirSync(dir)
.map((f) => 'storage/system_logs/' + f) .map((file) => {
const fullPath = `${dir}/${file}`
const stat = fs.statSync(fullPath)
return {
path: fullPath,
time: stat.mtime.getTime(), // hoặc stat.birthtime
}
})
.sort((a, b) => b.time - a.time) // giảm dần (mới nhất trước)
.slice(0, 1000) .slice(0, 1000)
.map((f) => f.path) // lấy lại path
io.to(socket.id).emit('list_logs', getListSystemLogs) io.to(socket.id).emit('list_logs', getListSystemLogs)
// const listHistory = await this.getHistory(data?.stationId, data?.lineId) // const listHistory = await this.getHistory(data?.stationId, data?.lineId)