service-core/example/api/core/ioroutes.mjs

29 lines
508 B
JavaScript
Raw Normal View History

2020-09-01 17:31:38 +00:00
import { formatLog } from './loghelper.mjs'
/*
* Event: 'core.config'
*
* Get config
*/
export async function config(ctx) {
ctx.socket.emit('core.config', ctx.config)
}
/*
* Event: 'core.getlastlogs'
*
* Returns last few log messages from log
*/
export async function getlastlogs(ctx, data, cb) {
cb(ctx.logroot.ringbuffer.records.map(formatLog))
}
/*
* Event: 'core.listenlogs'
*
* Start listening to new log lines
*/
export async function listenlogs(ctx) {
ctx.socket.join('logger')
}