import{a}from"./chunk-ICS3PEIS.mjs";import{a as g,b as i,e as c,f as m,g as o,h as l}from"./chunk-IFUYCFBO.mjs";import"./chunk-76CZ6Z7T.mjs";import n from"fs";import f from"path";var t="test-logs";c(()=>{l.clearAllMocks(),n.existsSync(t)&&n.rmSync(t,{recursive:!0,force:!0})});m(()=>{n.existsSync(t)&&n.rmSync(t,{recursive:!0,force:!0})});g("createLogger",async()=>{i("creates logger with default config",async()=>{let e=await a();o(e).toHaveProperty("info"),o(e).toHaveProperty("warn"),o(e).toHaveProperty("error"),o(e).toHaveProperty("debug"),o(e).toHaveProperty("flush")}),i("logs to console for stdout levels",async()=>{let e=l.spyOn(console,"log").mockImplementation(()=>{}),r=l.spyOn(console,"error").mockImplementation(()=>{}),s=await a({levels:{stdout:["warn","error"]}});s.warn("test","warning message"),s.error("test","error message"),s.info("test","info message"),o(e).toHaveBeenCalledWith(o.stringContaining("[WARN] warning message")),o(r).toHaveBeenCalledWith(o.stringContaining("[ERROR] error message")),o(e).not.toHaveBeenCalledWith(o.stringContaining("[INFO] info message"))}),i("writes to files in memory mode",async()=>{let e=await a({mode:"memory",logDir:t,levels:{file:["info","warn"]}});e.info("test","info message"),e.warn("test","warning message"),await e.flush();let r=n.readdirSync(t);o(r.length).toBeGreaterThan(0);let s=n.readFileSync(f.join(t,r[0]),"utf8");o(s).toContain("[INFO] info message"),o(s).toContain("[WARN] warning message")}),i("writes to single file when singleFile is true",async()=>{let e=await a({mode:"memory",logDir:t,singleFile:!0},!0);e.info("file1","message1"),e.info("file2","message2"),await e.flush();let r=n.readdirSync(t);o(r.length).toBe(1),o(r[0]).toMatch(/combined-/)}),i("creates log directory if it doesn't exist",async()=>{let e=await a({logDir:t});o(n.existsSync(t)).toBe(!0)}),i("handles stream mode",async()=>{let e=await a({mode:"stream",logDir:t});e.error("test","stream message"),await e.flush();let r=n.readdirSync(t);o(r.length).toBeGreaterThan(0)}),i("filters logs by level",async()=>{let e=await a({mode:"memory",logDir:t,levels:{file:["error"]}});e.info("test","info"),e.error("test","error"),await e.flush();let r=n.readdirSync(t),s=n.readFileSync(f.join(t,r[0]),"utf8");o(s).toContain("error"),o(s).not.toContain("info")})});
