private static function _formatFilePath($filename, $format, $extras = array(), $addHostname = false)
    {
        // we can parse scalars also
        if(is_scalar($extras)) {
            $extras = array($extras);
        }

        if(!is_array($extras)) {
            throw new \Exception('Extras parameter must be array');
        }

        $dot_pos  = strrpos($filename, '.');
        if(!$dot_pos) {
            $filename .= '.log';
            $dot_pos  = strrpos($filename, '.');
        }

        $tmp = strlen($filename) - $dot_pos;

        switch ($format) {
            case self::LOGPATH_FORMAT_COMPLEX:
                // add short date and 24 hour format as last parama
                $extras[] = $addHostname
                    ? substr($filename, 0, $dot_pos) . '_' . gethostname()
                    : substr($filename, 0, $dot_pos);
                $extras = array_merge($extras, explode('-', date("H-d-m-Y", Tools::ts())));
                // reverse order or extras array so that year is first, month etc...
                $extras = array_reverse($extras);
                $glue = DIRECTORY_SEPARATOR;
                break;

            default:
            case self::LOGPATH_FORMAT_SIMPLE:
                // add machine hostname to extra array
                $extras[] = substr($filename, 0, $dot_pos);
                if($addHostname) {
                    $extras[] = gethostname();
                }
                $extras[] = date("Y-m-d", Tools::ts());
                $glue = '_';
                break;
        }

        return implode($glue, $extras) . substr($filename,  "-{$tmp}", $tmp);
    }