private static function resolveLogLocation(array &$context) {
        if (!key_exists('trace', $context))
            self::generateStackTrace($context);
        $trace = $context['trace'];

        foreach ($trace as $i => $frame) {                  // find the first frame with "file"
            if (isset($frame['file'])) {                    // skip internal PHP functions
                $context['file'] = $frame['file'];
                $context['line'] = $frame['line'];
                break;
            }
        }

        if (!key_exists('file', $context)) {
            $context['file'] = '(unknown)';
            $context['line'] = '(?)';
        }
    }