Configuration
Loggy currently accepts a few different configuration options.
interface LoggyConfig { level: string; identifier: string; color?: boolean; compact?: boolean; timestamp?: boolean;}
The level
allows your to define what level to expose logs. This is useful for larger production level environments where you may not want to see everything. You can control your log level with env vars like so
const loggy = CreateLoggy({ level: `${env.ENVIRONMENT === "dev" ? 'info' : 'error'}` // show info and log messages in dev environments, error and log messages in non-dev environments identifier: "my-app", });
Identifier
Section titled “Identifier”The identifier
allows you to prefix messages with a custom string. Useful for if you have multiple services running in the same instance. You can instantiate multiple Loggy instances and prefix them accordingly, for example:
const serviceLoggy = CreateLoggy({ level: "error", identifier: "myService", });
const dbLoggy = CreateLoggy({ level: "warn", identifier: "myDb", });
Will print logs like
7/14/2025 9:16:28 PM [LOG] myService: This message is from your app service7/14/2025 9:17:14 PM [LOG] myDb: This message is from your db service
The color
allows you to toggle the pretty colors on and off. Defaults to true
.
Compact
Section titled “Compact”The compact
flag will collapse json objects. Defaults to false
.
Timestamp
Section titled “Timestamp”The timestamp
flag allows you to toggle showing the timestamp in logs. Defaults to true
.
Further reading
Section titled “Further reading”- See more about what’s on the roadmap