mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 18:44:16 +00:00
b6a95a8cb3
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix
38 lines
731 B
Go
38 lines
731 B
Go
// +build windows
|
|
|
|
package log
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
var (
|
|
kernel32 = syscall.MustLoadDLL("kernel32.dll")
|
|
procSetStdHandle = kernel32.MustFindProc("SetStdHandle")
|
|
)
|
|
|
|
func setStdHandle(stdhandle int32, handle syscall.Handle) error {
|
|
r0, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
|
|
if r0 == 0 {
|
|
if e1 != 0 {
|
|
return error(e1)
|
|
}
|
|
return syscall.EINVAL
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func CrashLog(file string) {
|
|
f, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
|
|
if err != nil {
|
|
log.Println(err.Error())
|
|
} else {
|
|
err = setStdHandle(syscall.STD_ERROR_HANDLE, syscall.Handle(f.Fd()))
|
|
if err != nil {
|
|
log.Println(err.Error())
|
|
}
|
|
}
|
|
}
|