File tree Expand file tree Collapse file tree 9 files changed +193
-0
lines changed
Expand file tree Collapse file tree 9 files changed +193
-0
lines changed Original file line number Diff line number Diff line change 1+ * text =auto
2+
3+ .gitattributes export-ignore
4+ .gitignore export-ignore
5+ README.md export-ignore
6+ CHANGELOG.md export-ignore
7+ LICENSE export-ignore
Original file line number Diff line number Diff line change 1+ # Created by .ignore support plugin (hsz.mobi)
2+ # ## macOS template
3+ # General
4+ .DS_Store
5+ .AppleDouble
6+ .LSOverride
7+
8+ # Icon must end with two \r
9+ Icon
10+
11+ # Thumbnails
12+ ._ *
13+
14+ # Files that might appear in the root of a volume
15+ .DocumentRevisions-V100
16+ .fseventsd
17+ .Spotlight-V100
18+ .TemporaryItems
19+ .Trashes
20+ .VolumeIcon.icns
21+ .com.apple.timemachine.donotpresent
22+
23+ # Directories potentially created on remote AFP share
24+ .AppleDB
25+ .AppleDesktop
26+ Network Trash Folder
27+ Temporary Items
28+ .apdisk
29+
Original file line number Diff line number Diff line change 1+ # Logs
2+ Quickly check your logs in the Craft 3 utilities section.
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " ether/logs" ,
3+ "description" : " Access logs from the CP" ,
4+ "version" : " 3.0.0" ,
5+ "type" : " craft-plugin" ,
6+ "minimum-stability" : " dev" ,
7+ "require" : {
8+ "craftcms/cms" : " ^3.0.0-RC1"
9+ },
10+ "autoload" : {
11+ "psr-4" : {
12+ "ether\\ logs\\ " : " src/"
13+ }
14+ },
15+ "support" : {
16+ "issues" : " https://github.com/ethercreative/logs"
17+ },
18+ "extra" : {
19+ "handle" : " logs" ,
20+ "name" : " Logs" ,
21+ "developer" : " Ether Creative" ,
22+ "developerUrl" : " https://ethercreative.co.uk" ,
23+
24+ "class" : " ether\\ logs\\ Logs" ,
25+ "schemaVersion" : " 3.0.0"
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ether \logs ;
4+
5+ use craft \base \Plugin ;
6+ use craft \events \RegisterComponentTypesEvent ;
7+ use craft \services \Utilities ;
8+ use yii \base \Event ;
9+
10+ class Logs extends Plugin
11+ {
12+
13+ public function init ()
14+ {
15+ parent ::init ();
16+
17+ Event::on (
18+ Utilities::class,
19+ Utilities::EVENT_REGISTER_UTILITY_TYPES ,
20+ function (RegisterComponentTypesEvent $ event ) {
21+ $ event ->types [] = Utility::class;
22+ }
23+ );
24+ }
25+
26+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ether \logs ;
4+
5+ use Craft ;
6+
7+ class Utility extends \craft \base \Utility
8+ {
9+
10+ public static function displayName (): string
11+ {
12+ return Craft::t ('logs ' , 'Logs ' );
13+ }
14+
15+ public static function id (): string
16+ {
17+ return 'logs ' ;
18+ }
19+
20+ public static function iconPath ()
21+ {
22+ return Craft::getAlias ('@ether/logs/utility_icon.svg ' );
23+ }
24+
25+ /**
26+ * @return string
27+ * @throws \Twig_Error_Loader
28+ * @throws \yii\base\Exception
29+ */
30+ public static function contentHtml (): string
31+ {
32+ $ logsDir = Craft::getAlias ('@storage/logs ' );
33+
34+ $ logFiles = array_values (array_filter (
35+ scandir ($ logsDir ),
36+ function ($ var ) {
37+ return $ var [0 ] != '. ' ;
38+ }
39+ ));
40+
41+ if (!count ($ logFiles ))
42+ return '<p>You don \'t have any log files.</p> ' ;
43+
44+ $ currentLog = Craft::$ app ->request ->get ('log ' , $ logFiles [0 ]);
45+
46+ $ log = file_get_contents ($ logsDir . '/ ' . $ currentLog );
47+
48+ return Craft::$ app ->view ->renderTemplate (
49+ 'logs/view ' ,
50+ compact ('currentLog ' , 'logFiles ' , 'log ' )
51+ );
52+ }
53+
54+ }
Original file line number Diff line number Diff line change 1+ <form >
2+ <select name =" log" onchange =" this.parentNode.submit()" >
3+ {% for file in logFiles %}
4+ <option {{ file == currentLog ? ' selected' }}>{{ file }}</option >
5+ {% endfor %}
6+ </select >
7+ </form >
8+
9+ <hr >
10+
11+ <pre style =" max-width:calc(100vw - 498px);overflow:auto;padding:0 24px;margin-left:-24px;" ><!--
12+ --> <code >{{ log }}</code >
13+ </pre >
You can’t perform that action at this time.
0 commit comments