tabby/clients/tabby-agent/src/logger.ts

24 lines
618 B
TypeScript
Raw Normal View History

2023-06-06 14:25:31 +00:00
import pino from "pino";
import { isBrowser } from "./env";
2023-06-06 14:25:31 +00:00
/**
* Stream not available in browser, will use default console output.
*/
const stream = isBrowser
2023-06-06 14:25:31 +00:00
? null
: /**
* Default rotating file locate at `~/.tabby/agent-logs/`.
*/
require("rotating-file-stream").createStream("tabby-agent.log", {
path: require("path").join(require("os").homedir(), ".tabby", "agent-logs"),
2023-06-06 14:25:31 +00:00
size: "10M",
interval: "1d",
});
export const rootLogger = !!stream ? pino(stream) : pino();
export const allLoggers = [rootLogger];
rootLogger.onChild = (child) => {
allLoggers.push(child);
};