Detangling snail actions. Also a cat

I started writing this post on the 8th of November and have just now gotten around to finishing it.

Figuring out what my snails are doing and why is getting close to impossible. I’ve got snails eating each other, or refusing to eat proper food, or for some reason not mating even though their sex drive should be pretty high. I used to print stuff out to one big default log file (laravel.log), but this soon became unmanageable because I was printing logs associated with multiple actions for multiple snails at the same time.

I ended up creating a logger for each snail:

    public function getLoggerAttribute() {
        $path = storage_path() . '/logs/' . $this->snailID . '.log';
        if (!File::exists($path)) {
            File::put($path, "");
        };
        $snailLog = new Logger('Snail Logs');
        $snailLog->pushHandler(new StreamHandler($path, Logger::INFO));
        return $snailLog;
    }

{:lang=“php”}

So now I can log relevant information to each snail’s individual log file. Example:

$this->snail->logger->addInfo("Override escape for hunger");

{:lang=“php”}

I think I need a couple of weeks of just bug fixing. I’m noticing a crapton of little issues. Some are easy things, others are weird behavioural things that I’ve been too lazy to try to debug.

And the reason I’ve been so lazy is because of this new distraction. Meet Rigel the Maine Coon kitten!

Rigel the Maine Coon

comments powered by Disqus