Skip to content

Commit

Permalink
fix: default winston logger
Browse files Browse the repository at this point in the history
  • Loading branch information
lopesdasilva committed Feb 20, 2024
1 parent 442331d commit 9d9d190
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 2 additions & 0 deletions ethereal-nexus-dashboard/src/app/(session)/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { DataTable } from '@/components/ui/data-table/data-table';
import { getProjects } from '@/data/projects/actions';
import { auth } from '@/auth';
import { columns } from '@/components/projects/table/columns';
import {logger} from "@/logger";

export default async function Projects() {
const session = await auth()
const projects = await getProjects(session?.user?.id);
logger.info("Projects Page called "); // calling our logger

return (
<div className="container h-full flex-1 flex-col space-y-8 p-8 md:flex">
Expand Down
2 changes: 1 addition & 1 deletion ethereal-nexus-dashboard/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async function Home() {
const session = await auth()
const projects = await getProjects(session?.user?.id);
logger.info("Home Page called "); // calling our logger
console.log("Home Page called "); // calling console.log

return <div className="container flex-col md:flex">
<div className="flex-1 space-y-4 p-8 pt-6">
<div className="flex items-center justify-between space-y-2">
Expand Down
28 changes: 20 additions & 8 deletions ethereal-nexus-dashboard/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import winston from "winston";
const { combine, timestamp, json } = winston.format;

/* Example logger with custom formatter
https://github.com/winstonjs/winston#combining-formats
const { combine, timestamp, label, prettyPrint } = winston.format;
const logger = winston.createLogger({
level: "info",
format: combine(timestamp(), json()),
transports: [
new winston.transports.File({
filename: "ethereal-nexus.log"
}),
],
format: combine(
label({ label: "NextJs NR Integration" }),
timestamp(),
prettyPrint()
),
transports: [new winston.transports.Console()],
});
*/

/* Example logger outputing to the console without formatting
const logger = winston.createLogger({
transports: [new winston.transports.Console()],
});
*/

// thsi will simply send logs to NR without outputting to the console
// best for prod environments
const logger = winston.createLogger();

export { logger };

0 comments on commit 9d9d190

Please sign in to comment.