-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
3,582 additions
and
7,058 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { define } from "@mvdlei/env"; | ||
import { type Level } from "@mvdlei/log"; | ||
import { z } from "zod"; | ||
|
||
export const env = define({ | ||
env: { | ||
NODE_ENV: z | ||
.string() | ||
.default("development") | ||
.transform((val) => val.toLowerCase()), | ||
}, | ||
prefix: "INTERNAL_", | ||
prefixed: { | ||
INTERNAL_LOG_LEVEL: z | ||
.enum(["error", "warn", "info", "http", "verbose", "debug", "silly"] as const) | ||
.default("info") | ||
.transform((val) => val.toLowerCase() as Level), | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { create } from "@mvdlei/log"; | ||
|
||
import { env } from "./env"; | ||
|
||
export const winston = create({ | ||
level: env.NODE_ENV === "production" ? "info" : env.INTERNAL_LOG_LEVEL ?? "info", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,31 @@ | ||
import winston from "winston"; | ||
import winston, { createLogger } from "winston"; | ||
|
||
export const defaultOptions: winston.LoggerOptions = { | ||
format: winston.format.combine(winston.format.timestamp(), winston.format.json()), | ||
transports: [new winston.transports.Console()], | ||
}; | ||
export type Level = "error" | "warn" | "info" | "verbose" | "debug" | "silly"; | ||
export interface LoggerOptions extends winston.LoggerOptions { | ||
level?: Level; | ||
} | ||
|
||
export const create = (options: winston.LoggerOptions = defaultOptions) => { | ||
return Logger.create(options); | ||
export const defaultOptions = { | ||
format: winston.format.combine( | ||
winston.format.colorize(), | ||
winston.format.simple(), | ||
winston.format.timestamp(), | ||
winston.format.printf((info) => { | ||
const { timestamp, level, message, ...rest } = info; | ||
return `${timestamp} [${level}]: ${message} ${ | ||
Object.keys(rest).length ? JSON.stringify(rest, null, 2) : "" | ||
}`; | ||
}), | ||
winston.format.errors({ stack: true }), | ||
), | ||
transports: [new winston.transports.Console()] as const, | ||
level: "debug", | ||
} satisfies LoggerOptions; | ||
|
||
export const create = (options: LoggerOptions = defaultOptions) => { | ||
return createLogger(options); | ||
}; | ||
|
||
export class Logger { | ||
private static _logger: winston.Logger; | ||
private static _instance: Logger; | ||
|
||
public static log = Logger._logger.log; | ||
public static error = Logger._logger.error; | ||
public static warn = Logger._logger.warn; | ||
public static info = Logger._logger.info; | ||
public static verbose = Logger._logger.verbose; | ||
public static debug = Logger._logger.debug; | ||
public static silly = Logger._logger.silly; | ||
|
||
public log = Logger._logger.log; | ||
public error = Logger._logger.error; | ||
public warn = Logger._logger.warn; | ||
public info = Logger._logger.info; | ||
public verbose = Logger._logger.verbose; | ||
public debug = Logger._logger.debug; | ||
public silly = Logger._logger.silly; | ||
|
||
public static create = (options: winston.LoggerOptions = defaultOptions) => { | ||
const _logger = Logger.getInstance(options); | ||
return _logger; | ||
}; | ||
|
||
public static getInstance = (options: winston.LoggerOptions = defaultOptions) => { | ||
if (!Logger._instance) { | ||
Logger._logger = winston.createLogger(options); | ||
Logger._instance = new Logger(options); | ||
} | ||
return Logger._instance; | ||
}; | ||
|
||
constructor(options: winston.LoggerOptions = defaultOptions) { | ||
Logger.getInstance(options); | ||
} | ||
} | ||
const logger = create(defaultOptions); | ||
|
||
export default Logger; | ||
logger.info("Hello, world!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from "./src/index"; | ||
export * from "./src/helpers"; | ||
export * from "./src/primitives"; | ||
export * from "./src/tests"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// export * from "./components/ui/accordion"; | ||
// export * from "./components/ui/alert"; | ||
// export * from "./components/ui/alert-dialog"; | ||
// export * from "./components/ui/aspect-ratio"; | ||
// export * from "./components/ui/avatar"; | ||
|
||
// export * from "./components/ui/badge"; | ||
// export * from "./components/ui/button"; | ||
|
||
// export * from "./components/ui/calendar"; | ||
// export * from "./components/ui/card"; | ||
// export * from "./components/ui/carousel"; | ||
// export * from "./components/ui/checkbox"; | ||
// export * from "./components/ui/collapsible"; | ||
// export * from "./components/ui/command"; | ||
// export * from "./components/ui/context-menu"; | ||
|
||
// export * from "./components/ui/dialog"; | ||
// export * from "./components/ui/drawer"; | ||
// export * from "./components/ui/dropdown-menu"; | ||
|
||
// export * from "./components/ui/form"; | ||
|
||
// export * from "./components/ui/hover-card"; | ||
|
||
// export * from "./components/ui/input"; | ||
|
||
// export * from "./components/ui/label"; | ||
|
||
// export * from "./components/ui/menubar"; | ||
|
||
// export * from "./components/ui/navigation-menu"; | ||
|
||
// export * from "./components/ui/pagination"; | ||
// export * from "./components/ui/popover"; | ||
// export * from "./components/ui/progress"; | ||
|
||
// export * from "./components/ui/radio-group"; | ||
// export * from "./components/ui/resizable"; | ||
|
||
// export * from "./components/ui/scroll-area"; | ||
// export * from "./components/ui/select"; | ||
// export * from "./components/ui/separator"; | ||
// export * from "./components/ui/sheet"; | ||
// export * from "./components/ui/skeleton"; | ||
// export * from "./components/ui/slider"; | ||
// export * from "./components/ui/sonner"; | ||
// export * from "./components/ui/switch"; | ||
|
||
// export * from "./components/ui/table"; | ||
// export * from "./components/ui/tabs"; | ||
// export * from "./components/ui/textarea"; | ||
// export * from "./components/ui/toast"; | ||
// export * from "./components/ui/toaster"; | ||
// export * from "./components/ui/toggle"; | ||
// export * from "./components/ui/toggle-group"; | ||
// export * from "./components/ui/tooltip"; |
Oops, something went wrong.