Skip to content

Commit d96f8fc

Browse files
committed
fix for console logger
1 parent e5218da commit d96f8fc

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "remix-development-tools",
33
"description": "Remix development tools - a set of tools for developing/debugging Remix.run apps",
44
"author": "Alem Tuzlak",
5-
"version": "4.1.0",
5+
"version": "4.1.1",
66
"license": "MIT",
77
"keywords": [
88
"remix",

src/test-apps/remix-vite/app/routes/_index.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,34 @@ import { json, redirect, type LoaderFunctionArgs, defer } from "@remix-run/node"
33
import type { MetaFunction } from "@remix-run/node";
44
import { Link, useFetcher, useSubmit } from "@remix-run/react";
55
import { Button } from "../components/Button";
6+
class Redis {
7+
constructor(url: string, options: any) {
8+
console.log("Redis constructor", url, options);
69

10+
}
11+
on(event: string, cb: any) {
12+
console.log("Redis on", event, cb);
13+
}
14+
removeAllListeners(event: string) {
15+
console.log("Redis removeAllListeners", event);
16+
}
17+
}
718
export const meta: MetaFunction = () => {
819
return [
920
{ title: "New Remix App" },
1021
{ name: "description", content: "Welcome to Remix!" },
1122
];
1223
};
13-
24+
export const redis = new Redis("url", {
25+
commandTimeout: 5000,
26+
enableAutoPipelining: true,
27+
maxRetriesPerRequest: 3,
28+
});
29+
redis.on("connect", () => console.debug("Redis connected"));
30+
redis.on("close", () => console.debug("Redis connection closed"));
31+
redis.on("reconnecting", () => console.log("Redis reconnecting"));
32+
redis.removeAllListeners("error");
33+
redis.on("error", (error: Error) => console.error("Redis error", error));
1434
export const loader = async ({ request }: LoaderFunctionArgs) => {
1535

1636
const test = new Promise((resolve) => {

src/vite/plugin.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
108108
if(code.includes("console.")) {
109109
const lines = code.split("\n");
110110
return lines.map((line, lineNumber) => {
111+
// Do not add for arrow functions
112+
if(line.replaceAll(" ", "").includes("=>console.")) {
113+
return line;
114+
}
115+
// Do not add if it is a return statement
116+
if(line.includes("return console.")) {
117+
return line;
118+
}
111119
const column = line.indexOf("console.");
112120
const logMessage = `"${chalk.magenta("LOG")} Logged in ${chalk.blueBright(`${id.replace(normalizePath(process.cwd()),"")}:${lineNumber+1}:${column+1}`)}"`;
113121
if (line.includes("console.log")) {

0 commit comments

Comments
 (0)