aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/ringlogger/global.go
blob: 60e750a5cda5a52e422092455a7a2ba83dbb41aa (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                         
             
                       

                                                 











                                         
                                                                        






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

package ringlogger

import (
	"log"
	"path/filepath"

	"golang.zx2c4.com/wireguard/windows/conf"
)

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(filepath.Join(root, "log.bin"), tag)
	if err != nil {
		return err
	}
	log.SetOutput(Global)
	log.SetFlags(0)
	return nil
}