generated from t3-oss/create-t3-turbo
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Logger package #75
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
6b965c0
start logger
t3dotgg 4df178c
add logger package
markflorkowski 25070ee
add web socket server
markflorkowski 377f877
support subscribing to different log levels
markflorkowski a998a91
add ws to trpc client
markflorkowski caf1d8e
remove old logger file
markflorkowski 7f16cc8
misc cleanup, start testing
markflorkowski 6d76049
Merge branch 'main' into theo/logger-example
t3dotgg b1e05f3
aaaaaaaaaaaa
t3dotgg de64023
add tsconfig
markflorkowski f97e5b5
add .gitignore
markflorkowski b27a5eb
lint
markflorkowski ce4cd24
misc cleanup, close server on SIGTERM
markflorkowski 600f93a
replace a bunch of console.logs
markflorkowski 4d50fff
replace more logs
markflorkowski 327513a
more cleanup
markflorkowski 1ff4193
a few more console logs swapped
markflorkowski 3b7fabd
no-console lint rule
markflorkowski 9d7f146
disable no-console on docs and marketing site
markflorkowski 7808c9e
add missing dep
markflorkowski ce5e4f9
pnpm i
markflorkowski e40d319
fix vscode side
t3dotgg ddc3050
Fix logger in cli
t3dotgg 4069899
allow passing Error objects to logger
markflorkowski 38eb801
missing file
markflorkowski 81cdfe1
Merge branch 'main' into theo/logger-example
markflorkowski aa5ab62
combine dev checks
markflorkowski 1e4af44
disable multiple eslint rules in one line
markflorkowski b5c8614
don't store ReactNodes in state
markflorkowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"apps/cli/cli-core", | ||
"apps/cli/cli-web", | ||
"apps/docs", | ||
"apps/marketing" | ||
"apps/marketing", | ||
"packages/logger" | ||
] | ||
} |
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
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,47 @@ | ||
import { ReactNode, useState } from "react"; | ||
import { cliApi } from "../utils/api"; | ||
|
||
import type { LogLevels } from "@captain/logger"; | ||
|
||
const colorMap = { | ||
trace: "text-gray-600", // gray | ||
debug: `text-cyan-600`, // cyan | ||
info: `text-white`, // white | ||
warn: `text-yellow-600`, // yellow | ||
error: `text-red-600`, // red | ||
} as const; | ||
|
||
const webFormat = (input: { level: LogLevels; message: string }) => { | ||
const { level, message } = input; | ||
return ( | ||
<span className={colorMap[level]}> | ||
<span className="font-semibold">{`[${level.toUpperCase()}]`}</span>{" "} | ||
{message} | ||
</span> | ||
); | ||
}; | ||
|
||
export const Logs = () => { | ||
const [messages, setMessages] = useState< | ||
{ level: LogLevels; message: string }[] | ||
>([]); | ||
cliApi.onLog.useSubscription(undefined, { | ||
onData: (data) => { | ||
setMessages((messages) => { | ||
return [...messages, data]; | ||
}); | ||
}, | ||
}); | ||
|
||
return ( | ||
<div className="flex h-96 flex-col overflow-y-auto rounded-md bg-gray-900 p-4"> | ||
{messages.map((message, index) => { | ||
return ( | ||
<div key={index} className="text-sm"> | ||
{webFormat(message)} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; |
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,22 +1,22 @@ | ||
#!/usr/bin/env node | ||
import { startServer } from "./server"; | ||
import { startServer, startSocketServer } from "./server"; | ||
import { renderTitle } from "./utils/renderTitle"; | ||
|
||
const DOCS_LINK = "https://docs.webhookthing.com"; | ||
|
||
const main = async () => { | ||
renderTitle(); | ||
|
||
// link to docs | ||
console.log( | ||
`\x1b[36m%s\x1b[0m`, | ||
`Questions? Check out the docs: ${DOCS_LINK}` | ||
); | ||
// eslint-disable-next-line no-console | ||
console.log(`\x1b[36mQuestions? Check out the docs: ${DOCS_LINK}\x1b[0m`); | ||
|
||
startSocketServer(); | ||
|
||
await startServer(); | ||
}; | ||
|
||
main().catch((err) => { | ||
// eslint-disable-next-line no-console | ||
console.error(err); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a component, should probably be mounted as such so it can be keyed and diffed accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also worth memoizing