private static function _writeLog($filename, $msg, $addTime = true)
    {
        // preppend details
        if($addTime) {
            $msg = self::formatHeaderWithTime() . $msg;
        }

        if(DI::has('BufferOptions')) {

            $options = DI::get('BufferConnectionOptions');

            $callback = function($data) use ($filename) {
                Writer::writeLogVerbose($filename, implode("\n\n", $data) . "\n\n");
            };

            // just to be on safe side, set max size to 500, that is reasonable number
            $maxSize = 500;

            $size = isset($options['size']) && is_int($options['size']) && $options['size'] > 0 && $options['size'] < $maxSize
                ? $options['size']
                : $maxSize;

            $buffer = new Buffer($filename, Buffer::ADAPTER_REDIS, $size, $callback, $options);
            $buffer->add($msg);

        } else {
            Writer::writeLogVerbose($filename, $msg);
        }
    }