File: windows.go

package info (click to toggle)
browserpass 3.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 4,836 kB
  • sloc: javascript: 80,027; makefile: 544
file content (28 lines) | stat: -rw-r--r-- 845 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// +build windows

package persistentlog

import (
	"os"
	"path/filepath"

	"github.com/rifflock/lfshook"
	log "github.com/sirupsen/logrus"
)

// AddPersistentLogHook configures persisting logs in a file
func AddPersistentLogHook() {
	appDataPath := os.Getenv("LOCALAPPDATA")
	if appDataPath == "" {
		log.Warn("Unable to determine %%APPDATA%% folder location, logs will NOT be persisted")
		return
	}
	logFolderPath := filepath.Join(appDataPath, "browserpass")
	if err := os.MkdirAll(logFolderPath, os.ModePerm); err != nil {
		log.Warn("Unable to create browserpass folder in %%APPDATA%%, logs will NOT be persisted: ", err)
		return
	}
	logFilePath := filepath.Join(logFolderPath, "browserpass.log")
	log.Debug("Logs will being written to: ", logFilePath)
	log.AddHook(lfshook.NewHook(logFilePath, &log.TextFormatter{FullTimestamp: true}))
}