UNPKG

modern-errors-winston

Version:
38 lines (25 loc) 650 B
import{ fullFormat as fullFormatLib, shortFormat as shortFormatLib, validateOptions}from "winston-error-format"; const getOptions=(options={})=>{ validateOptions(options); return options }; const getFormat=(formatLib,{errorInfo})=> formatLib(getErrorFormat.bind(undefined,errorInfo)); const getErrorFormat=(errorInfo,error)=>{ const{ options:{level,stack}, error:errorA }=errorInfo(error); return{level,stack,transform:()=>errorA} }; const shortFormat=getFormat.bind(undefined,shortFormatLib); const fullFormat=getFormat.bind(undefined,fullFormatLib); export default{ name:"winston", getOptions, staticMethods:{shortFormat,fullFormat} };