You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: log.go
    path of file: ./repos/gdlv
    
    the code of the file until where you have to start completion: package main

import (
	"fmt"
	"io"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"time"
)

var LogOutputNice, LogOutputRpc io.WriteCloser

func replacepid(in string) string {
	return strings.Replace(in, "%p", strconv.Itoa(os.Getpid()), -1)
}

func logf(fmtstr string, args ...interface{}) {
	if LogOutputNice == nil {
		return
	}
	if len(fmtstr) == 0 || fmtstr[len(fmtstr)-1] != '\n' {
		fmtstr = fmtstr + "\n"
	}
	LogOutputNice.Write([]byte(time.Now().Format(time.RFC3339
    
func setupLog() {
	tmpdir := getLogArchivesDir()
	if tmpdir == "" {
		return
	}

	cleanLogArchives(tmpdir)

	tmpdir = filepath.Join(tmpdir, fmt.Sprintf("%s-%d", time.Now().Format("20060102150405"), os.Getpid()))

	err := os.Mkdir(tmpdir, 0770)
	if err != nil {
		return
	}

	fhnice, err1 := os.Create(filepath.Join(tmpdir, "nice.log"))
	if err1 != nil {
		return
	}
	fhrpc, err2 := os.Create(filepath.Join(tmpdir, "rpc.log"))
	if err2 != nil {
		fhnice.Close()
		return
	}

	LogOutputNice = fhnice
	LogOutputRpc = fhrpc
}