aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/ringlogger/global.go
blob: da79b6de278103b2e29b5c8bcc370ef05ba2d5fa (plain) (tree)






























                                                                    
/* SPDX-License-Identifier: MIT
 *
 * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
 */

package ringlogger

import (
	"golang.zx2c4.com/wireguard/windows/conf"
	"log"
	"path"
)

var Global *Ringlogger

func InitGlobalLogger(tag string) error {
	if Global != nil {
		return nil
	}
	root, err := conf.RootDirectory()
	if err != nil {
		return err
	}
	Global, err = NewRinglogger(path.Join(root, "log.bin"), tag)
	if err != nil {
		return err
	}
	log.SetOutput(Global)
	log.SetFlags(0)
	return nil
}