Created
January 26, 2023 13:59
-
-
Save cballenar/fc48a6da7a2239c20c5dab2ad76ac444 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace yournamespace\yourplugin; | |
use Craft; | |
class MyClass | |
{ | |
/** | |
* Basic Logging implementation | |
*/ | |
protected function log($message): void | |
{ | |
$logFile = Craft::getAlias('@storage/logs/logname.log'); | |
$log = date('Y-m-d H:i:s').' '.serialize($message)."\n"; | |
\craft\helpers\FileHelper::writeToFile($logFile, $log, ['append' => true]); | |
} | |
// usage | |
self::log([$varToLog]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment