@@ -27,20 +27,6 @@ using json = nlohmann::json;
2727
2828extern MySQL_Logger *GloMyLogger;
2929
30- // Rotation mode is now read from thread variables instead of static globals
31-
32- // Helper functions to safely get rotation mode from thread variables
33- static std::string get_events_rotation_mode () {
34- return (mysql_thread___eventslog_file_rotation_mode &&
35- strcmp (mysql_thread___eventslog_file_rotation_mode, " external" ) == 0 ) ?
36- " external" : " internal" ;
37- }
38-
39- static std::string get_audit_rotation_mode () {
40- return (mysql_thread___auditlog_file_rotation_mode &&
41- strcmp (mysql_thread___auditlog_file_rotation_mode, " external" ) == 0 ) ?
42- " external" : " internal" ;
43- }
4430
4531using metric_name = std::string;
4632using metric_help = std::string;
@@ -1266,13 +1252,15 @@ void MySQL_Logger::audit_close_log_unlocked() {
12661252void MySQL_Logger::events_flush_log_unlocked () {
12671253 if (events.enabled ==false ) return ;
12681254
1269- if (get_events_rotation_mode () == " external" ) {
1270- // External rotation mode - just flush the current file
1255+ // Special handling for stdout/stderr - just flush without rotation
1256+ if (events.base_filename &&
1257+ (strcmp (events.base_filename , " /dev/stdout" ) == 0 ||
1258+ strcmp (events.base_filename , " /dev/stderr" ) == 0 )) {
12711259 if (events.logfile ) {
12721260 events.logfile ->flush ();
12731261 }
12741262 } else {
1275- // Internal rotation mode - create numbered files (original behavior)
1263+ // Normal files - use numbered rotation (original behavior)
12761264 events_close_log_unlocked ();
12771265 events_open_log_unlocked ();
12781266 }
@@ -1281,13 +1269,15 @@ void MySQL_Logger::events_flush_log_unlocked() {
12811269void MySQL_Logger::audit_flush_log_unlocked () {
12821270 if (audit.enabled ==false ) return ;
12831271
1284- if (get_audit_rotation_mode () == " external" ) {
1285- // External rotation mode - just flush the current file
1272+ // Special handling for stdout/stderr - just flush without rotation
1273+ if (audit.base_filename &&
1274+ (strcmp (audit.base_filename , " /dev/stdout" ) == 0 ||
1275+ strcmp (audit.base_filename , " /dev/stderr" ) == 0 )) {
12861276 if (audit.logfile ) {
12871277 audit.logfile ->flush ();
12881278 }
12891279 } else {
1290- // Internal rotation mode - create numbered files (original behavior)
1280+ // Normal files - use numbered rotation (original behavior)
12911281 audit_close_log_unlocked ();
12921282 audit_open_log_unlocked ();
12931283 }
@@ -1296,17 +1286,14 @@ void MySQL_Logger::audit_flush_log_unlocked() {
12961286void MySQL_Logger::events_open_log_unlocked () {
12971287 char *filen=NULL ;
12981288
1299- if (get_events_rotation_mode () == " external" ) {
1300- // External rotation mode - use basename file (no numbering)
1301- if (events.base_filename [0 ]==' /' ) { // absolute path
1302- filen=(char *)malloc (strlen (events.base_filename )+1 );
1303- strcpy (filen, events.base_filename );
1304- } else { // relative path
1305- filen=(char *)malloc (strlen (events.datadir )+strlen (events.base_filename )+2 );
1306- sprintf (filen," %s/%s" ,events.datadir ,events.base_filename );
1307- }
1289+ // Special handling for stdout/stderr - use filename as-is without numbering
1290+ if (events.base_filename &&
1291+ (strcmp (events.base_filename , " /dev/stdout" ) == 0 ||
1292+ strcmp (events.base_filename , " /dev/stderr" ) == 0 )) {
1293+ filen=(char *)malloc (strlen (events.base_filename )+1 );
1294+ strcpy (filen, events.base_filename );
13081295 } else {
1309- // Internal rotation mode - use numbered files (original behavior)
1296+ // Normal files - use numbered files (original behavior)
13101297 events.log_file_id =events_find_next_id ();
13111298 if (events.log_file_id !=0 ) {
13121299 events.log_file_id =events_find_next_id ()+1 ;
@@ -1359,17 +1346,14 @@ void MySQL_Logger::events_open_log_unlocked() {
13591346void MySQL_Logger::audit_open_log_unlocked () {
13601347 char *filen=NULL ;
13611348
1362- if (get_audit_rotation_mode () == " external" ) {
1363- // External rotation mode - use basename file (no numbering)
1364- if (audit.base_filename [0 ]==' /' ) { // absolute path
1365- filen=(char *)malloc (strlen (audit.base_filename )+1 );
1366- strcpy (filen, audit.base_filename );
1367- } else { // relative path
1368- filen=(char *)malloc (strlen (audit.datadir )+strlen (audit.base_filename )+2 );
1369- sprintf (filen," %s/%s" ,audit.datadir ,audit.base_filename );
1370- }
1349+ // Special handling for stdout/stderr - use filename as-is without numbering
1350+ if (audit.base_filename &&
1351+ (strcmp (audit.base_filename , " /dev/stdout" ) == 0 ||
1352+ strcmp (audit.base_filename , " /dev/stderr" ) == 0 )) {
1353+ filen=(char *)malloc (strlen (audit.base_filename )+1 );
1354+ strcpy (filen, audit.base_filename );
13711355 } else {
1372- // Internal rotation mode - use numbered files (original behavior)
1356+ // Normal files - use numbered files (original behavior)
13731357 audit.log_file_id =audit_find_next_id ();
13741358 if (audit.log_file_id !=0 ) {
13751359 audit.log_file_id =audit_find_next_id ()+1 ;
@@ -2121,29 +2105,3 @@ void MySQL_Logger::p_update_metrics() {
21212105 gauges[ml_g::circular_buffer_events_size]->Set (MyLogCB->size ());
21222106}
21232107
2124- // Rotation mode configuration functions (now using thread variables)
2125- void MySQL_Logger::set_eventslog_rotation_mode (const std::string& mode) {
2126- if (mode == " internal" || mode == " external" ) {
2127- if (mysql_thread___eventslog_file_rotation_mode) {
2128- free (mysql_thread___eventslog_file_rotation_mode);
2129- }
2130- mysql_thread___eventslog_file_rotation_mode = strdup (mode.c_str ());
2131- }
2132- }
2133-
2134- void MySQL_Logger::set_auditlog_rotation_mode (const std::string& mode) {
2135- if (mode == " internal" || mode == " external" ) {
2136- if (mysql_thread___auditlog_file_rotation_mode) {
2137- free (mysql_thread___auditlog_file_rotation_mode);
2138- }
2139- mysql_thread___auditlog_file_rotation_mode = strdup (mode.c_str ());
2140- }
2141- }
2142-
2143- std::string MySQL_Logger::get_eventslog_rotation_mode () const {
2144- return get_events_rotation_mode ();
2145- }
2146-
2147- std::string MySQL_Logger::get_auditlog_rotation_mode () const {
2148- return get_audit_rotation_mode ();
2149- }
0 commit comments