@lunora/cli
Version:
The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands
3 lines (2 loc) • 1.03 kB
JavaScript
import{STEP_BADGE_NAMES as u,LunoraReporter as i}from"@lunora/config";import{JsonReporter as a}from"@visulima/pail/reporter/json";import{createPail as p}from"@visulima/pail/server";let n,c=!1;const g=()=>{if(c)return!0;const r=process.env.LUNORA_LOG_JSON;return r==="1"||r==="true"},l=r=>new r,f=()=>[l(g()?a:i)],L=()=>{c||(c=!0,n=void 0)},d=Object.fromEntries(u.map(r=>[r,{label:r,logLevel:"informational"}])),o=()=>(n??=p({reporters:f(),scope:["lunora"],stderr:process.stderr,stdout:process.stdout,types:d}),n),P=()=>({debug:r=>{o().debug(r)},error:r=>{o().error(r)},info:r=>{o().info(r)},success:r=>{o().success(r)},warn:r=>{o().warn(r)}}),S=()=>{const r=(e,t)=>{process.stderr.write(`${e} ${t}
`)};return{debug:e=>{r("debug",e)},error:e=>{r("error",e)},info:e=>{r("info ",e)},success:e=>{r("ok ",e)},warn:e=>{r("warn ",e)}}},_=new Proxy({},{get(r,e){const t=o(),s=t[e];return typeof s=="function"?s.bind(t):s}}),E=(r,e)=>{o()[r](e)};export{P as createLogger,S as createStderrLogger,L as forceJsonLogging,E as logStep,_ as pail};