refactor: Replace console logging with logger utility

- Add logger import across multiple view components
- Replace console.error/warn/log with logger methods
- Update error handling to use structured logging
- Improve type safety for error objects
- Add crypto-browserify polyfill for browser environment

The changes improve logging by:
1. Using consistent logging interface
2. Adding structured error logging
3. Improving error type safety
4. Centralizing logging configuration
5. Fixing browser compatibility issues

Affected files:
- Multiple view components
- vite.config.ts
- Build configuration
This commit is contained in:
Matthew Raymer
2025-03-11 09:35:55 +00:00
parent 515bb38db4
commit c9536dd643
1781 changed files with 81616 additions and 401 deletions

View File

@@ -252,6 +252,7 @@ import {
} from "../libs/endorserServer";
import * as libsUtil from "../libs/util";
import EntityIcon from "../components/EntityIcon.vue";
import { logger } from "../utils/logger";
/**
* DIDView Component
@@ -517,7 +518,7 @@ export default class DIDView extends Vue {
);
}
} catch (error) {
console.error("Error when registering:", error);
logger.error("Error when registering:", error);
let userMessage = "There was an error.";
const serverError = error as AxiosError;
if (serverError) {
@@ -551,7 +552,7 @@ export default class DIDView extends Vue {
*/
public async loadClaimsAbout() {
if (!this.viewingDid) {
console.error("This should never be called without a DID.");
logger.error("This should never be called without a DID.");
return;
}
@@ -573,7 +574,7 @@ export default class DIDView extends Vue {
if (response.status !== 200) {
const details = await response.text();
console.error("Problem with full search:", details);
logger.error("Problem with full search:", details);
this.$notify(
{
group: "alert",
@@ -592,7 +593,7 @@ export default class DIDView extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.error("Error with feed load:", e);
logger.error("Error with feed load:", e);
this.$notify(
{
group: "alert",
@@ -733,7 +734,7 @@ export default class DIDView extends Vue {
}
return true;
} else {
console.error("Got strange result from setting visibility:", result);
logger.error("Got strange result from setting visibility:", result);
const message =
(result.error as string) || "Could not set visibility on the server.";
this.$notify(
@@ -796,7 +797,7 @@ export default class DIDView extends Vue {
3000,
);
} else {
console.error("Got bad server response checking visibility:", resp);
logger.error("Got bad server response checking visibility:", resp);
const message = resp.data.error?.message || "Got bad server response.";
this.$notify(
{
@@ -809,7 +810,7 @@ export default class DIDView extends Vue {
);
}
} catch (err) {
console.error("Caught error from request to check visibility:", err);
logger.error("Caught error from request to check visibility:", err);
this.$notify(
{
group: "alert",