diff --git a/public/api/create_user.php b/public/api/create_user.php index 5a57722..9709a55 100644 --- a/public/api/create_user.php +++ b/public/api/create_user.php @@ -135,7 +135,24 @@ exec($cmd . ' 2>&1', $output, $returnVar); $json = implode("\n", $output); // Optional: write raw output into logs for debugging -@file_put_contents(__DIR__ . '/../logs/create_user_output.log', date('Y-m-d H:i:s') . ' CMD: ' . $cmd . "\n" . $json . "\n\n", FILE_APPEND | LOCK_EX); +$ts = date('Y-m-d H:i:s'); + +$ctx = [ + 'cmd' => $cmd, + 'return_code' => $returnVar, + 'output' => $json, +]; + +$line = sprintf( + "[%s] %-7s %s %s%s", + $ts, + 'DEBUG', + 'PowerShell CMD', + json_encode($ctx, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + PHP_EOL +); + +@file_put_contents(__DIR__ . '/../logs/create_user_output.log', $line, FILE_APPEND | LOCK_EX); @unlink($tmpFile); diff --git a/public/api/create_users_csv.php b/public/api/create_users_csv.php index 216f903..49ef5f1 100644 --- a/public/api/create_users_csv.php +++ b/public/api/create_users_csv.php @@ -82,7 +82,24 @@ $json = implode("\n", $output); @unlink($metaFile); // Optional: log the CSV script command and raw output to help debugging -@file_put_contents(__DIR__ . '/../logs/create_users_csv_output.log', date('Y-m-d H:i:s') . ' CMD: ' . $cmd . "\n" . $json . "\n\n", FILE_APPEND | LOCK_EX); +$ts = date('Y-m-d H:i:s'); + +$ctx = [ + 'cmd' => $cmd, + 'return_code' => $returnVar, + 'output' => $json, +]; + +$line = sprintf( + "[%s] %-7s %s %s%s", + $ts, + 'DEBUG', + 'PowerShell CMD', + json_encode($ctx, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + PHP_EOL +); + +@file_put_contents(__DIR__ . '/../logs/create_users_csv_output.log', $line, FILE_APPEND | LOCK_EX); $result = null; if ($json !== '') {