Skip to content

Commit

Permalink
fix: don't log the entire moment.js object
Browse files Browse the repository at this point in the history
fixes #1453
  • Loading branch information
RangerRick committed Feb 14, 2024
1 parent 08e9209 commit de573cd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import DateTimeFormatter from "./formats/DateTimeFormatter";

const register = (moment, fatal = true) => {
if (moment && moment.fn.zoneAbbr) {
console.log("register:", moment, fatal);
console.log("register: moment=%s, fatal=%s", typeof moment, fatal);
if (moment.tz) {
console.log(
"Moment.js with timezone support detected; attaching Java format methods."
"Moment.js with timezone support detected; attaching Java format methods.",
);
} else {
console.warn(
"Moment.js detected, but timezone support is missing. Some Java formatting features may not work as expected."
"Moment.js detected, but timezone support is missing. Some Java formatting features may not work as expected.",
);
}

Expand All @@ -30,7 +30,7 @@ const register = (moment, fatal = true) => {
return moment;
} else {
console.error(
"Unable to attach Java format methods. Moment.js object was invalid."
"Unable to attach Java format methods. Moment.js object was invalid.",
);
if (fatal) {
throw new Error("Moment.js object was invalid.");
Expand All @@ -54,14 +54,14 @@ if (typeof window !== "undefined" && window?.moment) {
window.moment = register(moment, false);
} catch (err) {
console.warn(
"Failed to load moment-timezone. Attempting fallback to moment."
"Failed to load moment-timezone. Attempting fallback to moment.",
);
try {
const moment = require("moment");
window.moment = register(moment, false);
} catch (subErr) {
console.warn(
"Failed to load moment. User will have to manually register."
"Failed to load moment. User will have to manually register.",
);
}
}
Expand Down

0 comments on commit de573cd

Please sign in to comment.