Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaHaceCosas committed Jun 25, 2024
1 parent c3147cb commit e2ac0fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Cuando la app llegue a un punto en el que es utilizable y se publique el primer
## 0.0.1-R5-b19

- Renamed most variables to take a more descriptive and easy to understand approach.
- Decided to set an internal standard for console logging: `termLog` (imported from `DeveloperInterface.tsx`). This will `console.log` and log for Dev interface aswell.

## 0.0.1-R5-b18

Expand Down
32 changes: 7 additions & 25 deletions app/DeveloperInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,23 @@ export const testLog = (

// Styled log with prefixes
let prefix = "";
let style = "";
switch (type) {
case "success":
prefix = "GOD";
style =
"font-weight: bold; background: #30FF97; color: black; padding: 2px 4px; border-radius: 2px;";
break;
case "error":
prefix = "ERR";
style = "color: #ff0000; font-weight: bold;";
break;
case "warn":
prefix = "WAR";
style = "color: #ff9900; font-weight: bold;";
break;
default:
prefix = "LOG";
style = "color: #000000; font-weight: bold;";
break;
}

console.log(`%c${prefix} %c${logMessage}`, style, "");
const log = prefix + " " + message;
console.log(log);
};

export const termLog = (
Expand Down Expand Up @@ -171,7 +166,6 @@ export default function ConsoleLogger() {

React.useEffect(() => {
setLogs(globalLogs);

console.log = (message: string, ...optionalParams: unknown[]) => {
const newLog: Log = {
message: message.toString(),
Expand Down Expand Up @@ -222,32 +216,20 @@ export default function ConsoleLogger() {
const storedObjs = await AsyncStorage.getItem("objs");
if (storedObjs) {
setObjs(JSON.parse(storedObjs));
console.log(
"%cGOD%cAll is ok%c Objectives (OBJS) fetched and parsed!",
"font-weight: bold; background: #30FF97; color: black; padding: 2px 4px; border-radius: 2px;",
"font-weight: bold; background: white; color: black; padding: 2px 4px; border-radius: 2px;",
"color: #30FF97;"
);
termLog("Objectives (OBJS) fetched and parsed!", "success");
} else {
await AsyncStorage.setItem("objs", JSON.stringify({}));
setObjs({});
console.log(
"%cWOR%cDev error%c Could not get objectives (OBJS) fetched! Setting them to an empty array ( {} )",
"font-weight: bold; background: #FFD700; color: black; padding: 2px 4px; border-radius: 2px;",
"font-weight: bold; background: white; color: black; padding: 2px 4px; border-radius: 2px;",
"color: #FFD700;"
termLog(
"Could not get objectives (OBJS) fetched! Setting them to an empty array ( {} )",
"warn"
);
}
} catch (e) {
const log =
"Could not get objectives (OBJS) fetched due to error: " +
e;
console.log(
"%cWOR%cDev error%c " + log,
"font-weight: bold; background: #FFD700; color: black; padding: 2px 4px; border-radius: 2px;",
"font-weight: bold; background: white; color: black; padding: 2px 4px; border-radius: 2px;",
"color: #FFD700;"
);
termLog(log, "error");
}
};

Expand Down

0 comments on commit e2ac0fb

Please sign in to comment.