This repository was archived by the owner on Apr 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,11 @@ import { typeCast } from './utils/typeCast';
33export const mysql_connection_string = GetConvar ( 'mysql_connection_string' , '' ) ;
44export let mysql_ui = GetConvar ( 'mysql_ui' , 'false' ) === 'true' ;
55export let mysql_slow_query_warning = GetConvarInt ( 'mysql_slow_query_warning' , 200 ) ;
6- export let mysql_debug : boolean | string [ ] ;
6+ export let mysql_debug : boolean | string [ ] = false ;
7+
8+ // max array size of individual resource query logs
9+ // prevent excessive memory use when people use debug/ui in production
10+ export let mysql_log_size = 0 ;
711
812export function setDebug ( ) {
913 mysql_ui = GetConvar ( 'mysql_ui' , 'false' ) === 'true' ;
@@ -15,6 +19,8 @@ export function setDebug() {
1519 } catch ( e ) {
1620 mysql_debug = true ;
1721 }
22+
23+ mysql_log_size = mysql_debug ? 10000 : GetConvarInt ( 'mysql_log_size' , 100 ) ;
1824}
1925
2026export const mysql_transaction_isolation_level = ( ( ) => {
@@ -87,9 +93,7 @@ export const connectionOptions = (() => {
8793 try {
8894 options [ key ] = JSON . parse ( value ) ;
8995 } catch ( err ) {
90- console . log (
91- `^3Failed to parse property ${ key } in configuration (${ err } )!^0`
92- )
96+ console . log ( `^3Failed to parse property ${ key } in configuration (${ err } )!^0` ) ;
9397 }
9498 }
9599 }
Original file line number Diff line number Diff line change 11import { PoolConnection , RowDataPacket } from 'mysql2/promise' ;
2- import { mysql_debug , mysql_slow_query_warning , mysql_ui } from '../config' ;
2+ import { mysql_debug , mysql_log_size , mysql_slow_query_warning , mysql_ui } from '../config' ;
33import type { CFXCallback , CFXParameters } from '../types' ;
44import { dbVersion } from '../database' ;
55
@@ -109,7 +109,9 @@ export const logQuery = (
109109
110110 if ( ! mysql_ui ) return ;
111111
112- if ( logStorage [ invokingResource ] === undefined ) logStorage [ invokingResource ] = [ ] ;
112+ if ( ! logStorage [ invokingResource ] ) logStorage [ invokingResource ] = [ ] ;
113+ else if ( logStorage [ invokingResource ] . length > mysql_log_size ) logStorage [ invokingResource ] . splice ( 0 , 1 ) ;
114+
113115 logStorage [ invokingResource ] . push ( {
114116 query,
115117 executionTime,
You can’t perform that action at this time.
0 commit comments