Add logger and gitignore output.
Since the current workflow includes running files directly, SvelteKit's $dev env won't work. Using Node envs directly.
This commit is contained in:
parent
2c3f9be58f
commit
009b1925e6
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,6 +8,9 @@ node_modules
|
|||||||
/.svelte-kit
|
/.svelte-kit
|
||||||
/build
|
/build
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
*.log
|
||||||
|
|
||||||
# Databases
|
# Databases
|
||||||
*.db
|
*.db
|
||||||
|
|
||||||
|
|||||||
32
src/lib/server/logger.ts
Normal file
32
src/lib/server/logger.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import pino from "pino";
|
||||||
|
|
||||||
|
const prod = process.env.NODE_ENV === "production";
|
||||||
|
|
||||||
|
const loggerConfig: Record<string, pino.LoggerOptions> = {
|
||||||
|
prod: {
|
||||||
|
level: "info",
|
||||||
|
},
|
||||||
|
dev: {
|
||||||
|
level: "debug",
|
||||||
|
transport: {
|
||||||
|
targets: [
|
||||||
|
{
|
||||||
|
target: "pino-pretty",
|
||||||
|
options: {
|
||||||
|
colorize: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: "pino/file",
|
||||||
|
options: {
|
||||||
|
destination: "./logs/dev.log",
|
||||||
|
mkdir: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const logger = pino(prod ? loggerConfig.prod : loggerConfig.dev);
|
||||||
|
|
||||||
|
export default logger;
|
||||||
Loading…
Reference in New Issue
Block a user