Skip to content

Commit 3d98702

Browse files
committed
runWithoutLogging
1 parent b3abd1f commit 3d98702

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

app/routes/MdxRoute.res

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ let components = {
4747
"Warn": Markdown.Warn.make,
4848
}
4949

50+
// the loadAllMdx function logs out all of the file contents as it reads them, which is noisy and not useful.
51+
// We can suppress that logging with this helper function.
52+
let allMdx = await Shims.runWithoutLogging(() => loadAllMdx())
53+
5054
let loader: Loader.t<loaderData> = async ({request}) => {
5155
let mdx = await loadMdx(request)
5256

53-
let fileContents = await (await loadAllMdx(~filterByPaths=["docs"]))
57+
let fileContents = await allMdx
5458
->Array.filter(mdx => (mdx.path :> string)->String.includes("docs/manual/introduction"))
5559
->Array.get(0)
5660
->Option.map(mdx => mdx.path)
@@ -94,8 +98,6 @@ let default = () => {
9498

9599
let {categories, entries} = useLoaderData()
96100

97-
Console.log(entries)
98-
99101
let metaTitleCategory =
100102
(pathname :> string)->String.includes("docs/manual")
101103
? "ReScript Language Manual"

compilers/dummy/Dummy.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Console.log("I am a dummy file")
1+
Console.debug("I am a dummy file")

scripts/generate_feed.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ let content = {
33
getLatest()->toXmlString
44
}
55

6-
Console.log(content)
6+
Console.debug(content)

src/Shims.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@module("./shims.js")
2+
external runWithoutLogging: (unit => Promise.t<'a>) => Promise.t<'a> = "runWithoutLogging"

src/components/Markdown.res

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ module H2 = {
138138
@react.component
139139
let make = (~id, ~children) => {
140140
let title = childrenToString(children)->String.toLowerCase->String.replaceAll(" ", "-")
141-
142-
Console.log(title)
143-
144141
<>
145142
// Here we know that children is always a string (## headline)
146143
<h2 id className="group mt-16 mb-3 hl-3 scroll-mt-32">

src/layouts/DocsLayout.res

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ let make = (
116116
}}
117117
</div>
118118

119-
Console.log2("activeToc", activeToc)
120-
121119
let sidebar =
122120
<Sidebar isOpen=isSidebarOpen toggle=toggleSidebar preludeSection ?activeToc categories route />
123121

src/shims.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const runWithoutLogging = async (fn) => {
2+
const orig = console.log;
3+
console.log = () => { };
4+
const values = await fn();
5+
console.log = orig;
6+
return values;
7+
}

0 commit comments

Comments
 (0)