4 examples

Excessive logging

Excessive logging statements causing performance or readability issues.

[ FAQ1 ]

What is excessive logging?

Excessive logging occurs when an application logs too much information, often at overly verbose or unnecessary levels like debug, producing large volumes of logs that obscure important messages. This log spam can degrade application performance, complicate log analysis, and increase storage and processing costs. Typically, excessive logging results from improper log-level configuration, debugging statements left in production, or overly granular logging practices.
[ FAQ2 ]

How to fix excessive logging in code

To fix excessive logging, carefully configure log levels (such as ERROR, WARN, INFO, DEBUG) to ensure only meaningful, context-appropriate information is recorded in production environments. Remove or refactor verbose debug statements after resolving issues, reducing unnecessary log output. Implement log rotation, structured logging, or sampling techniques to manage log volume effectively. Regularly review and audit logging practices, balancing the need for debugging information with performance considerations and readability, ensuring logs remain useful and manageable.
diff block
NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.ever.team
NEXT_PUBLIC_GA_MEASUREMENT_ID=
+# Logs Configuration
+LOG_FOLDER_MAX_SIZE=10
+NEXT_PUBLIC_LOG_FOLDER_MAX_SIZE=10 ## in Mb
+ACTIVE_LOCAL_LOG_SYSTEM=true
+NEXT_PUBLIC_ACTIVE_LOCAL_LOG_SYSTEM=true
Greptile
greptile
style: Consider setting ACTIVE_LOCAL_LOG_SYSTEM to false by default in sample file to prevent excessive logging
diff block
+import { useEffect, useState } from "react";
+import { getPreferenceValues, List, showToast, Toast } from "@raycast/api";
+import { Workflow } from "./types/types";
+import { getAllWorkflowsAPI } from "./utils/n8n-api-utils";
+import { getWebhookDetails } from "./utils/workflow-utils";
+import { EmptyView } from "./components/empty-view";
+
+// Define the preferences interface matching package.json
+interface Preferences {
+ instanceUrl: string;
+ apiKey: string;
+}
+
+export default function SearchWebhookWorkflowsCommand() {
+ const { instanceUrl, apiKey } = getPreferenceValues<Preferences>();
+
+ const [filteredWorkflows, setFilteredWorkflows] = useState<Workflow[]>([]); // Workflows after filtering
+ const [loading, setLoading] = useState<boolean>(true);
+ const [error, setError] = useState<string | null>(null);
+ const [refresh, setRefresh] = useState<number>(0); // To trigger manual refresh
+
+ useEffect(() => {
+ async function loadAndFilterWorkflows() {
+ console.log("Rendering SearchWebhookWorkflowsCommand");
+ if (!instanceUrl || !apiKey) {
+ setError("Missing API Credentials");
+ setLoading(false);
+ await showToast({
+ style: Toast.Style.Failure,
+ title: "Missing Preferences",
+ message: "Please set your n8n Instance URL and API Key in the command preferences.",
+ });
+ return;
+ }
+
+ setLoading(true);
+ setError(null);
+ try {
+ // 1. Load saved filters with validation
+ // const storedFilters = await LocalStorage.getItem<string>(TRIGGER_FILTERS_KEY);
+ // let currentFilters: string[] = [];
+
+ // if (storedFilters) {
+ // try {
+ // const parsedFilters = JSON.parse(storedFilters);
+
+ // // Validate filters are in the expected format
+ // if (Array.isArray(parsedFilters)) {
+ // // Filter out non-string values
+ // currentFilters = parsedFilters.filter(item => typeof item === 'string');
+
+ // // If we found invalid items, save the cleaned version back
+ // if (currentFilters.length !== parsedFilters.length) {
+ // console.warn(`Found ${parsedFilters.length - currentFilters.length} invalid filter items, cleaning up`);
+ // await LocalStorage.setItem(TRIGGER_FILTERS_KEY, JSON.stringify(currentFilters));
+ // }
+ // } else {
+ // console.warn("Saved filters are not in array format, resetting");
+ // await LocalStorage.removeItem(TRIGGER_FILTERS_KEY);
+ // }
+ // } catch (parseError) {
+ // console.error("Failed to parse saved filters:", parseError);
+ // await LocalStorage.removeItem(TRIGGER_FILTERS_KEY);
+ // }
+ // }
+
+ // setActiveFilters(currentFilters); // Update state for UI indicator
+
+ // 2. Fetch all workflows
+ console.log("Fetching all workflows");
+ const fetchedWorkflows = await getAllWorkflowsAPI();
+ console.log(`Fetched ${fetchedWorkflows.length} workflows`);
+
+ // 3. First filter for webhook triggers
+ console.log("Filtering for webhook triggers");
+ const webhookWorkflows = fetchedWorkflows.filter(wf => {
+ const hasWebhook = getWebhookDetails(wf) !== null;
+ console.log(`Workflow ${wf.name} (${wf.id}) has webhook: ${hasWebhook}`);
+ return hasWebhook;
+ });
Greptile
greptile
excessive logging in filter callback may impact performance with large workflow lists
diff block
&self.k,
&self.v,
);
+ tracing::info!(?t, "---------------------");
t.pack(w, tuple_depth)
Greptile
greptile
style: This debug log statement may generate excessive logging in production since it's at info level and runs on every tuple pack operation. Consider removing or changing to trace level.
suggested fix
+ tracing::trace!(?t, "packing tuple");
+ t.pack(w, tuple_depth)
diff block
+import { City, Reader, ReaderModel } from '@maxmind/geoip2-node'
+import { join } from 'path'
+import { Counter } from 'prom-client'
+
+import { Hub, PluginsServerConfig } from '../types'
+import { status } from './status'
+
+export type GeoIp = {
+ city: (ip: string) => City | null
+}
+
+export const geoipCompareCounter = new Counter({
+ name: 'cdp_geoip_compare_count',
+ help: 'Number of times we compare the MMDB file to the local file',
+ labelNames: ['result'],
+})
+
+export class GeoIPService {
+ private _mmdbPromise: Promise<ReaderModel> | undefined
+
+ constructor(private config: PluginsServerConfig) {}
+
+ private getMmdb() {
+ if (!this._mmdbPromise) {
+ this._mmdbPromise = Reader.open(join(this.config.BASE_DIR, this.config.MMDB_FILE_LOCATION))
+ }
+
+ return this._mmdbPromise
+ }
+
+ async get(hub: Hub): Promise<GeoIp> {
+ // NOTE: There is a lot of code here just testing that the values are the same as before.
+ // Once released we don't need the Hub and can simplify this.
+ let mmdb: ReaderModel | undefined
+ try {
+ mmdb = await this.getMmdb()
+ } catch (e) {
+ if (!this.config.MMDB_COMPARE_MODE) {
+ // If we aren't comparing then we should fail hard
+ throw e
+ }
+ }
+
+ return {
+ city: (ip: string) => {
+ if (typeof ip !== 'string') {
+ return null
+ }
+
+ let newGeoipResult: City | null = null
+ let oldGeoipResult: City | null = null
+
+ try {
+ if (this.config.MMDB_COMPARE_MODE) {
+ oldGeoipResult = hub.mmdb?.city(ip) ?? null
+ }
+ } catch {}
+
+ try {
+ if (mmdb) {
+ newGeoipResult = mmdb.city(ip)
+ }
+ } catch {}
+
Greptile
greptile
logic: Remove these console.log statements before merging to production. They will create excessive logging in production environments.
suggested fix