[GH-ISSUE #6] mclogs fix #4

Closed
opened 2026-05-07 00:16:56 +02:00 by BreizhHardware · 1 comment

Originally created by @ConsoleGods on GitHub (Dec 20, 2025).
Original GitHub issue: https://github.com/pelican-dev/plugins/issues/6

This was fixed with Claude since i have no idea how to code. The problem was in UploadLogsAction.php

`<?php
namespace Boy132\MclogsUploader\Filament\Components\Actions;

use App\Models\Server;
use Exception;
use Filament\Actions\Action;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Support\Enums\Size;
use Illuminate\Support\Facades\Http;

class UploadLogsAction extends Action
{
public static function getDefaultName(): ?string
{
return 'upload_logs';
}

protected function setUp(): void
{
    parent::setUp();

    $this->hidden(function () {
        /** @var Server $server */
        $server = Filament::getTenant();

        return $server->retrieveStatus()->isOffline();
    });

    $this->label(fn () => trans('mclogs-uploader::upload.upload_logs'));
    $this->icon('tabler-upload');
    $this->color('primary');
    $this->size(Size::ExtraLarge);

    $this->action(function () {
        /** @var Server $server */
        $server = Filament::getTenant();

        try {
            $logs = Http::daemon($server->node)
                ->get("/api/servers/{$server->uuid}/logs")
                ->throw()
                ->json('data');

            // Ensure logs is a string
            if (empty($logs)) {
                throw new Exception('No logs found on server');
            }

            // Convert array to string if needed
            $logContent = is_array($logs) ? implode("\n", $logs) : (string)$logs;

            // Make sure we have content
            if (empty(trim($logContent))) {
                throw new Exception('Log content is empty');
            }

            $response = Http::asForm()
                ->timeout(15)
                ->connectTimeout(5)
                ->post('https://api.mclo.gs/1/log', [
                    'content' => $logContent,
                ]);

            // Check if request was successful
            if (!$response->successful()) {
                throw new Exception('Upload failed with status ' . $response->status() . ': ' . $response->body());
            }

            $responseData = $response->json();

            if ($responseData['success']) {
                Notification::make()
                    ->title(trans('mclogs-uploader::upload.uploaded'))
                    ->body($responseData['url'])
                    ->persistent()
                    ->success()
                    ->send();
            } else {
                Notification::make()
                    ->title(trans('mclogs-uploader::upload.upload_failed'))
                    ->body($responseData['error'] ?? 'Unknown error')
                    ->danger()
                    ->send();
            }
        } catch (Exception $exception) {
            \Log::error('Upload logs error:', [
                'message' => $exception->getMessage(),
                'trace' => $exception->getTraceAsString()
            ]);
            
            report($exception);
            
            Notification::make()
                ->title(trans('mclogs-uploader::upload.upload_failed'))
                ->body($exception->getMessage())
                ->danger()
                ->send();
        }
    });
}

}`

Originally created by @ConsoleGods on GitHub (Dec 20, 2025). Original GitHub issue: https://github.com/pelican-dev/plugins/issues/6 This was fixed with Claude since i have no idea how to code. The problem was in UploadLogsAction.php `<?php namespace Boy132\MclogsUploader\Filament\Components\Actions; use App\Models\Server; use Exception; use Filament\Actions\Action; use Filament\Facades\Filament; use Filament\Notifications\Notification; use Filament\Support\Enums\Size; use Illuminate\Support\Facades\Http; class UploadLogsAction extends Action { public static function getDefaultName(): ?string { return 'upload_logs'; } protected function setUp(): void { parent::setUp(); $this->hidden(function () { /** @var Server $server */ $server = Filament::getTenant(); return $server->retrieveStatus()->isOffline(); }); $this->label(fn () => trans('mclogs-uploader::upload.upload_logs')); $this->icon('tabler-upload'); $this->color('primary'); $this->size(Size::ExtraLarge); $this->action(function () { /** @var Server $server */ $server = Filament::getTenant(); try { $logs = Http::daemon($server->node) ->get("/api/servers/{$server->uuid}/logs") ->throw() ->json('data'); // Ensure logs is a string if (empty($logs)) { throw new Exception('No logs found on server'); } // Convert array to string if needed $logContent = is_array($logs) ? implode("\n", $logs) : (string)$logs; // Make sure we have content if (empty(trim($logContent))) { throw new Exception('Log content is empty'); } $response = Http::asForm() ->timeout(15) ->connectTimeout(5) ->post('https://api.mclo.gs/1/log', [ 'content' => $logContent, ]); // Check if request was successful if (!$response->successful()) { throw new Exception('Upload failed with status ' . $response->status() . ': ' . $response->body()); } $responseData = $response->json(); if ($responseData['success']) { Notification::make() ->title(trans('mclogs-uploader::upload.uploaded')) ->body($responseData['url']) ->persistent() ->success() ->send(); } else { Notification::make() ->title(trans('mclogs-uploader::upload.upload_failed')) ->body($responseData['error'] ?? 'Unknown error') ->danger() ->send(); } } catch (Exception $exception) { \Log::error('Upload logs error:', [ 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString() ]); report($exception); Notification::make() ->title(trans('mclogs-uploader::upload.upload_failed')) ->body($exception->getMessage()) ->danger() ->send(); } }); } }`
Author
Owner

@coderabbitai[bot] commented on GitHub (Dec 20, 2025):

📝 CodeRabbit Plan Mode

Generate an implementation plan and prompts that you can use with your favorite coding agent.

  • Create Plan
Examples


🧪 Issue enrichment is currently in open beta.

You can configure auto-planning by selecting labels in the issue_enrichment configuration.

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

💬 Have feedback or questions? Drop into our discord or schedule a call!

<!-- gh-comment-id:3677189342 --> @coderabbitai[bot] commented on GitHub (Dec 20, 2025): <!-- This is an auto-generated issue plan by CodeRabbit --> ### 📝 CodeRabbit Plan Mode Generate an implementation plan and prompts that you can use with your favorite coding agent. - [ ] <!-- {"checkboxId": "8d4f2b9c-3e1a-4f7c-a9b2-d5e8f1c4a7b9"} --> Create Plan <details> <summary>Examples</summary> - [Example 1](https://github.com/coderabbitai/git-worktree-runner/issues/29#issuecomment-3589134556) - [Example 2](https://github.com/coderabbitai/git-worktree-runner/issues/12#issuecomment-3606665167) </details> --- --- <details> <summary> 🧪 Issue enrichment is currently in open beta.</summary> You can configure auto-planning by selecting labels in the issue_enrichment configuration. To disable automatic issue enrichment, add the following to your `.coderabbit.yaml`: ```yaml issue_enrichment: auto_enrich: enabled: false ``` </details> 💬 Have feedback or questions? Drop into our [discord](https://discord.gg/coderabbit) or [schedule a call](https://calendly.com/parth-coderabbit/issues-feedback)!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/plugins#4
No description provided.