Skip to content

Commit

Permalink
feat(observability): implements client side logging configuration
Browse files Browse the repository at this point in the history
refs #436
  • Loading branch information
ygrishajev committed Nov 29, 2024
1 parent e3b6a5c commit 4e3a43e
Show file tree
Hide file tree
Showing 8 changed files with 9,185 additions and 29,426 deletions.
1 change: 1 addition & 0 deletions apps/stats-web/mvm.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"@akashnetwork/logging": "2.0.2",
"@akashnetwork/network-store": "1.0.1",
"@akashnetwork/ui": "1.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions apps/stats-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"start": "next start"
},
"dependencies": {
"@akashnetwork/logging": "*",
"@akashnetwork/network-store": "*",
"@akashnetwork/ui": "*",
"@cosmjs/encoding": "^0.32.4",
Expand Down
3 changes: 2 additions & 1 deletion apps/stats-web/src/config/browser-env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export const browserEnvConfig = validateStaticEnvVars({
NEXT_PUBLIC_NODE_ENV: process.env.NEXT_PUBLIC_NODE_ENV,
NEXT_PUBLIC_BASE_API_TESTNET_URL: process.env.NEXT_PUBLIC_BASE_API_TESTNET_URL,
NEXT_PUBLIC_BASE_API_SANDBOX_URL: process.env.NEXT_PUBLIC_BASE_API_SANDBOX_URL,
NEXT_PUBLIC_BASE_API_MAINNET_URL: process.env.NEXT_PUBLIC_BASE_API_MAINNET_URL
NEXT_PUBLIC_BASE_API_MAINNET_URL: process.env.NEXT_PUBLIC_BASE_API_MAINNET_URL,
NEXT_PUBLIC_LOG_LEVEL: process.env.NEXT_PUBLIC_LOG_LEVEL
});
3 changes: 2 additions & 1 deletion apps/stats-web/src/config/env-config.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const browserEnvSchema = z.object({
NEXT_PUBLIC_NODE_ENV: z.enum(["development", "production", "test"]).optional().default("development"),
NEXT_PUBLIC_BASE_API_TESTNET_URL: z.string().url(),
NEXT_PUBLIC_BASE_API_SANDBOX_URL: z.string().url(),
NEXT_PUBLIC_BASE_API_MAINNET_URL: z.string().url()
NEXT_PUBLIC_BASE_API_MAINNET_URL: z.string().url(),
NEXT_PUBLIC_LOG_LEVEL: z.enum(["fatal", "error", "warn", "info", "debug", "trace"]).optional().default("info")
});

export const serverEnvSchema = browserEnvSchema.extend({
Expand Down
7 changes: 7 additions & 0 deletions apps/stats-web/src/config/logger.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use client";

import { LoggerService } from "@akashnetwork/logging";

import { browserEnvConfig } from "@/config/browser-env.config";

LoggerService.configure({ LOG_LEVEL: browserEnvConfig.NEXT_PUBLIC_LOG_LEVEL });
8 changes: 8 additions & 0 deletions apps/stats-web/src/hooks/useLogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "../config/logger.config";

import { useMemo } from "react";
import { LoggerService } from "@akashnetwork/logging";

export const useLogger = (context: string) => {
return useMemo(() => LoggerService.forContext(context), [context]);
};
Loading

0 comments on commit 4e3a43e

Please sign in to comment.