-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace ether\logs; | ||
|
||
use Craft; | ||
use craft\base\Component; | ||
|
||
class Service extends Component | ||
{ | ||
|
||
public function truncate ($log) | ||
{ | ||
$logsDir = Craft::getAlias('@storage/logs'); | ||
file_put_contents($logsDir . DIRECTORY_SEPARATOR . $log, ''); | ||
Craft::$app->getSession()->setNotice($log . ' truncated.'); | ||
} | ||
|
||
public function delete ($log) | ||
{ | ||
$logsDir = Craft::getAlias('@storage/logs'); | ||
unlink($logsDir . DIRECTORY_SEPARATOR . $log); | ||
Craft::$app->getSession()->setNotice($log . ' deleted.'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
<form> | ||
<div style="display:flex;align-items:center;justify-content:space-between"> | ||
<label class="select"> | ||
<select id="__logSwitch"> | ||
{% for file in logFiles %} | ||
<option{{ file == currentLog ? ' selected' }}>{{ file }}</option> | ||
{% endfor %} | ||
</select> | ||
</label> | ||
</form> | ||
|
||
{% if currentUser.admin %} | ||
<form class="btngroup" method="post"> | ||
<button name="action" value="logs/logs/truncate" class="btn caution" title="Empty this log file">Truncate</button> | ||
{{ csrfInput() }} | ||
{{ hiddenInput('log', currentLog) }} | ||
<button name="action" value="logs/logs/delete" class="btn caution" title="Delete this log file">Delete</button> | ||
</form> | ||
{% endif %} | ||
</div> | ||
|
||
<hr style="margin-bottom:0"> | ||
|
||
<pre style="flex-grow:1;overflow:auto;padding:24px 24px 48px;margin:0 -24px;"><!-- | ||
<pre style="flex-grow:1;overflow:auto;padding:24px;margin:0 -24px -24px;"><!-- | ||
--><code id="__log">Loading...</code> | ||
</pre> |