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

24 lines
621 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
: /**
2023-07-03 06:16:19 +00:00
* Default rotating file locate at `~/.tabby/agent/logs/`.
2023-06-06 14:25:31 +00:00
*/
require("rotating-file-stream").createStream("tabby-agent.log", {
2023-07-03 06:16:19 +00:00
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);
};