Skip to content

Commit

Permalink
feat: pinoを使ったロガーを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Jan 7, 2025
1 parent fccc594 commit fd4ff85
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 49 deletions.
32 changes: 32 additions & 0 deletions app/modules/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pino from "pino";
import pretty from "pino-pretty";

let _logger: pino.Logger | undefined;

const DEFAULT_PRETTY_OPTIONS = {
colorize: true,
sync: true,
messageFormat: "{method}: {msg}",
hideObject: false,
ignore: "pid,hostname",
} as const satisfies pretty.PrettyOptions;

export const logFactory = (name: string) => {
if (_logger) {
return _logger;
}

const prettyStream = pretty(DEFAULT_PRETTY_OPTIONS);

_logger = pino(
{
name,
formatters: {
level: (label: string) => ({ level: label }),
},
timestamp: pino.stdTimeFunctions.isoTime,
},
prettyStream
);
return _logger;
};
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
"@radix-ui/react-dropdown-menu": "^2.1.3",
"@radix-ui/react-navigation-menu": "^1.2.2",
"@radix-ui/react-slot": "^1.1.1",
"@react-router/node": "^7.0.2",
"@react-router/serve": "^7.0.2",
"@react-router/node": "^7.1.1",
"@react-router/serve": "^7.1.1",
"@t3-oss/env-core": "^0.11.1",
"@tabler/icons-react": "^3.26.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"dotenv": "^16.4.7",
"isbot": "^5.1.17",
"lucide-react": "^0.468.0",
"pino": "^9.6.0",
"pino-pretty": "^13.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router": "^7.0.2",
"react-router": "^7.1.1",
"remix-auth": "^4.1.0",
"remix-auth-openid": "^0.3.0",
"tailwind-merge": "^2.5.5",
Expand All @@ -34,7 +36,7 @@
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@react-router/dev": "^7.0.2",
"@react-router/dev": "^7.1.1",
"@types/node": "^20.17.10",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
Expand Down
Loading

0 comments on commit fd4ff85

Please sign in to comment.