MCPcopy Index your code
hub / github.com/callstack/agent-device / readRecentNetworkTraffic

Function readRecentNetworkTraffic

src/daemon/network-log.ts:74–105  ·  view source on GitHub ↗
(
  logPath: string,
  options?: {
    backend?: LogBackend;
    maxEntries?: number;
    include?: NetworkIncludeMode;
    maxPayloadChars?: number;
    maxScanLines?: number;
  },
)

Source from the content-addressed store, hash-verified

72}
73
74export function readRecentNetworkTraffic(
75 logPath: string,
76 options?: {
77 backend?: LogBackend;
78 maxEntries?: number;
79 include?: NetworkIncludeMode;
80 maxPayloadChars?: number;
81 maxScanLines?: number;
82 },
83): NetworkDump {
84 const maxEntries = clampInt(options?.maxEntries, 25, 1, 200);
85 const include = options?.include ?? 'summary';
86 const maxPayloadChars = clampInt(options?.maxPayloadChars, 2048, 64, 16_384);
87 const maxScanLines = clampInt(options?.maxScanLines, 4000, 100, 20_000);
88 if (!fs.existsSync(logPath)) {
89 return {
90 path: logPath,
91 exists: false,
92 scannedLines: 0,
93 matchedLines: 0,
94 entries: [],
95 include,
96 limits: { maxEntries, maxPayloadChars, maxScanLines },
97 };
98 }
99
100 const content = fs.readFileSync(logPath, 'utf8');
101 return readRecentNetworkTrafficFromText(content, {
102 ...options,
103 path: logPath,
104 });
105}
106
107export function readRecentNetworkTrafficFromText(
108 content: string,

Callers 2

Calls 2

clampIntFunction · 0.70

Tested by

no test coverage detected