aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ringlogger/global.go
diff options
context:
space:
mode:
Diffstat (limited to 'ringlogger/global.go')
-rw-r--r--ringlogger/global.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/ringlogger/global.go b/ringlogger/global.go
new file mode 100644
index 00000000..da79b6de
--- /dev/null
+++ b/ringlogger/global.go
@@ -0,0 +1,31 @@
+/* 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
+}