Home / File/ Logger.js — react Source File

Logger.js — react Source File

Architecture documentation for Logger.js, a javascript file in the react codebase. 1 imports, 2 dependents.

File javascript BabelCompiler Validation 1 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  1c1420b7_ac86_a15c_84e2_cc784faf684d["Logger.js"]
  ae1017d8_c18a_3ecd_18f4_bf7a64bbd91a["react-devtools-feature-flags"]
  1c1420b7_ac86_a15c_84e2_cc784faf684d --> ae1017d8_c18a_3ecd_18f4_bf7a64bbd91a
  e2c52a93_982e_407f_9fee_e89aa134ae9d["DevTools.js"]
  e2c52a93_982e_407f_9fee_e89aa134ae9d --> 1c1420b7_ac86_a15c_84e2_cc784faf684d
  2e5340ff_c18c_8b58_8a45_86e8bb6884f5["hookNamesCache.js"]
  2e5340ff_c18c_8b58_8a45_86e8bb6884f5 --> 1c1420b7_ac86_a15c_84e2_cc784faf684d
  style 1c1420b7_ac86_a15c_84e2_cc784faf684d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow strict-local
 */

import {enableLogger} from 'react-devtools-feature-flags';

export type LoggerEvent =
  | {
      +event_name: 'loaded-dev-tools',
    }
  | {
      +event_name: 'error',
      +error_message: string | null,
      +error_stack: string | null,
      +error_component_stack: string | null,
    }
  | {
      +event_name: 'selected-components-tab',
    }
  | {
      +event_name: 'selected-profiler-tab',
    }
  | {
      +event_name: 'selected-suspense-tab',
    }
  | {
      +event_name: 'load-hook-names',
      +event_status: 'success' | 'error' | 'timeout' | 'unknown',
      +duration_ms: number,
      +inspected_element_display_name: string | null,
      +inspected_element_number_of_hooks: number | null,
    }
  | {
      +event_name: 'select-element',
      +metadata: {
        +source: string,
      },
    }
  | {
      +event_name: 'inspect-element-button-clicked',
    }
  | {
      +event_name: 'profiling-start',
      +metadata: {
        +current_tab: string,
      },
    }
  | {
      +event_name: 'profiler-tab-changed',
      +metadata: {
        +tabId: string,
      },
    }
  | {
      +event_name: 'settings-changed',
      +metadata: {
        +key: string,
        +value: any,
        ...
      },
    }
  | {
      +event_name: 'selected-editor-pane',
    }
  | {+event_name: 'selected-inspected-element-pane'};

export type LogFunction = LoggerEvent => void | Promise<void>;

let logFunctions: Array<LogFunction> = [];
export const logEvent: LogFunction =
  enableLogger === true
    ? function logEvent(event: LoggerEvent): void {
        logFunctions.forEach(log => {
          log(event);
        });
      }
    : function logEvent() {};

export const registerEventLogger: (logFunction: LogFunction) => () => void =
  enableLogger === true
    ? function registerEventLogger(logFunction: LogFunction): () => void {
        if (enableLogger) {
          logFunctions.push(logFunction);
          return function unregisterEventLogger() {
            logFunctions = logFunctions.filter(log => log !== logFunction);
          };
        }
        return () => {};
      }
    : function registerEventLogger(logFunction: LogFunction) {
        return () => {};
      };

Domain

Subdomains

Functions

Dependencies

  • react-devtools-feature-flags

Frequently Asked Questions

What does Logger.js do?
Logger.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in Logger.js?
Logger.js defines 1 function(s): LogFunction.
What does Logger.js depend on?
Logger.js imports 1 module(s): react-devtools-feature-flags.
What files import Logger.js?
Logger.js is imported by 2 file(s): DevTools.js, hookNamesCache.js.
Where is Logger.js in the architecture?
Logger.js is located at packages/react-devtools-shared/src/Logger.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free