Updated command to use new logging

This commit is contained in:
NotZippy
2017-09-02 09:10:21 -07:00
parent 3f136726db
commit 9d57681ae6
9 changed files with 73 additions and 130 deletions

View File

@@ -60,9 +60,9 @@ func NewAppCmd(binPath string, port int) AppCmd {
func (cmd AppCmd) Start() error { func (cmd AppCmd) Start() error {
listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool)} listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool)}
cmd.Stdout = listeningWriter cmd.Stdout = listeningWriter
revel.TRACE.Println("Exec app:", cmd.Path, cmd.Args) revel.RevelLog.Debug("Exec app:","path", cmd.Path,"args", cmd.Args)
if err := cmd.Cmd.Start(); err != nil { if err := cmd.Cmd.Start(); err != nil {
revel.ERROR.Fatalln("Error running:", err) revel.RevelLog.Fatal("Error running:","error", err)
} }
select { select {
@@ -70,7 +70,7 @@ func (cmd AppCmd) Start() error {
return errors.New("revel/harness: app died") return errors.New("revel/harness: app died")
case <-time.After(30 * time.Second): case <-time.After(30 * time.Second):
revel.TRACE.Println("Killing revel server process did not respond after wait timeout", cmd.Process.Pid) revel.RevelLog.Debug("Killing revel server process did not respond after wait timeout", cmd.Process.Pid)
cmd.Kill() cmd.Kill()
return errors.New("revel/harness: app timed out") return errors.New("revel/harness: app timed out")
@@ -84,19 +84,19 @@ func (cmd AppCmd) Start() error {
// Run the app server inline. Never returns. // Run the app server inline. Never returns.
func (cmd AppCmd) Run() { func (cmd AppCmd) Run() {
revel.TRACE.Println("Exec app:", cmd.Path, cmd.Args) revel.RevelLog.Debug("Exec app:","path", cmd.Path,"args", cmd.Args)
if err := cmd.Cmd.Run(); err != nil { if err := cmd.Cmd.Run(); err != nil {
revel.ERROR.Fatalln("Error running:", err) revel.RevelLog.Fatal("Error running:","error", err)
} }
} }
// Kill terminates the app server if it's running. // Kill terminates the app server if it's running.
func (cmd AppCmd) Kill() { func (cmd AppCmd) Kill() {
if cmd.Cmd != nil && (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) { if cmd.Cmd != nil && (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) {
revel.TRACE.Println("Killing revel server pid", cmd.Process.Pid) revel.RevelLog.Debug("Killing revel server pid","pid", cmd.Process.Pid)
err := cmd.Process.Kill() err := cmd.Process.Kill()
if err != nil { if err != nil {
revel.ERROR.Fatalln("Failed to kill revel server:", err) revel.RevelLog.Fatal("Failed to kill revel server:","error", err)
} }
} }
} }

View File

@@ -59,12 +59,12 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) {
// It relies on the user having "go" installed. // It relies on the user having "go" installed.
goPath, err := exec.LookPath("go") goPath, err := exec.LookPath("go")
if err != nil { if err != nil {
revel.ERROR.Fatalf("Go executable not found in PATH.") revel.RevelLog.Fatalf("Go executable not found in PATH.")
} }
pkg, err := build.Default.Import(revel.ImportPath, "", build.FindOnly) pkg, err := build.Default.Import(revel.ImportPath, "", build.FindOnly)
if err != nil { if err != nil {
revel.ERROR.Fatalln("Failure importing", revel.ImportPath) revel.RevelLog.Fatal("Failure importing", "path", revel.ImportPath)
} }
// Binary path is a combination of $GOBIN/revel.d directory, app's import path and its name. // Binary path is a combination of $GOBIN/revel.d directory, app's import path and its name.
@@ -109,14 +109,14 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) {
flags = append(flags, path.Join(revel.ImportPath, "app", "tmp")) flags = append(flags, path.Join(revel.ImportPath, "app", "tmp"))
buildCmd := exec.Command(goPath, flags...) buildCmd := exec.Command(goPath, flags...)
revel.TRACE.Println("Exec:", buildCmd.Args) revel.RevelLog.Debug("Exec:", "args", buildCmd.Args)
output, err := buildCmd.CombinedOutput() output, err := buildCmd.CombinedOutput()
// If the build succeeded, we're done. // If the build succeeded, we're done.
if err == nil { if err == nil {
return NewApp(binName), nil return NewApp(binName), nil
} }
revel.ERROR.Println(string(output)) revel.RevelLog.Error(string(output))
// See if it was an import error that we can go get. // See if it was an import error that we can go get.
matches := importErrorPattern.FindStringSubmatch(string(output)) matches := importErrorPattern.FindStringSubmatch(string(output))
@@ -133,10 +133,10 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) {
// Execute "go get <pkg>" // Execute "go get <pkg>"
getCmd := exec.Command(goPath, "get", pkgName) getCmd := exec.Command(goPath, "get", pkgName)
revel.TRACE.Println("Exec:", getCmd.Args) revel.RevelLog.Debug("Exec:", "args", getCmd.Args)
getOutput, err := getCmd.CombinedOutput() getOutput, err := getCmd.CombinedOutput()
if err != nil { if err != nil {
revel.ERROR.Println(string(getOutput)) revel.RevelLog.Error(string(getOutput))
return nil, newCompileError(output) return nil, newCompileError(output)
} }
@@ -144,7 +144,7 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) {
} }
// TODO remove this unreachable code and document it // TODO remove this unreachable code and document it
revel.ERROR.Fatalf("Not reachable") revel.RevelLog.Fatalf("Not reachable")
return nil, nil return nil, nil
} }
@@ -168,11 +168,11 @@ func getAppVersion() string {
return "" return ""
} }
gitCmd := exec.Command(gitPath, "--git-dir="+gitDir, "describe", "--always", "--dirty") gitCmd := exec.Command(gitPath, "--git-dir="+gitDir, "describe", "--always", "--dirty")
revel.TRACE.Println("Exec:", gitCmd.Args) revel.RevelLog.Debug("Exec:", "args", gitCmd.Args)
output, err := gitCmd.Output() output, err := gitCmd.Output()
if err != nil { if err != nil {
revel.WARN.Println("Cannot determine git repository version:", err) revel.RevelLog.Warn("Cannot determine git repository version:", "error", err)
return "" return ""
} }
@@ -189,12 +189,12 @@ func cleanSource(dirs ...string) {
} }
func cleanDir(dir string) { func cleanDir(dir string) {
revel.INFO.Println("Cleaning dir " + dir) revel.RevelLog.Info("Cleaning dir " + dir)
tmpPath := filepath.Join(revel.AppPath, dir) tmpPath := filepath.Join(revel.AppPath, dir)
f, err := os.Open(tmpPath) f, err := os.Open(tmpPath)
if err != nil { if err != nil {
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
revel.ERROR.Println("Failed to clean dir:", err) revel.RevelLog.Error("Failed to clean dir:", "error", err)
} }
} else { } else {
defer func() { defer func() {
@@ -204,20 +204,20 @@ func cleanDir(dir string) {
infos, err := f.Readdir(0) infos, err := f.Readdir(0)
if err != nil { if err != nil {
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
revel.ERROR.Println("Failed to clean dir:", err) revel.RevelLog.Error("Failed to clean dir:", "error", err)
} }
} else { } else {
for _, info := range infos { for _, info := range infos {
path := filepath.Join(tmpPath, info.Name()) pathName := filepath.Join(tmpPath, info.Name())
if info.IsDir() { if info.IsDir() {
err := os.RemoveAll(path) err := os.RemoveAll(pathName)
if err != nil { if err != nil {
revel.ERROR.Println("Failed to remove dir:", err) revel.RevelLog.Error("Failed to remove dir:", "error", err)
} }
} else { } else {
err := os.Remove(path) err := os.Remove(pathName)
if err != nil { if err != nil {
revel.ERROR.Println("Failed to remove file:", err) revel.RevelLog.Error("Failed to remove file:", "error", err)
} }
} }
} }
@@ -237,20 +237,20 @@ func genSource(dir, filename, templateSource string, args map[string]interface{}
tmpPath := filepath.Join(revel.AppPath, dir) tmpPath := filepath.Join(revel.AppPath, dir)
err := os.Mkdir(tmpPath, 0777) err := os.Mkdir(tmpPath, 0777)
if err != nil && !os.IsExist(err) { if err != nil && !os.IsExist(err) {
revel.ERROR.Fatalf("Failed to make '%v' directory: %v", dir, err) revel.RevelLog.Fatalf("Failed to make '%v' directory: %v", dir, err)
} }
// Create the file // Create the file
file, err := os.Create(filepath.Join(tmpPath, filename)) file, err := os.Create(filepath.Join(tmpPath, filename))
if err != nil { if err != nil {
revel.ERROR.Fatalf("Failed to create file: %v", err) revel.RevelLog.Fatalf("Failed to create file: %v", err)
} }
defer func() { defer func() {
_ = file.Close() _ = file.Close()
}() }()
if _, err = file.WriteString(sourceCode); err != nil { if _, err = file.WriteString(sourceCode); err != nil {
revel.ERROR.Fatalf("Failed to write to file: %v", err) revel.RevelLog.Fatalf("Failed to write to file: %v", err)
} }
} }
@@ -298,7 +298,7 @@ func addAlias(aliases map[string]string, importPath, pkgName string) {
func makePackageAlias(aliases map[string]string, pkgName string) string { func makePackageAlias(aliases map[string]string, pkgName string) string {
i := 0 i := 0
alias := pkgName alias := pkgName
for containsValue(aliases, alias) || alias=="revel" { for containsValue(aliases, alias) || alias == "revel" {
alias = fmt.Sprintf("%s%d", pkgName, i) alias = fmt.Sprintf("%s%d", pkgName, i)
i++ i++
} }
@@ -323,7 +323,7 @@ func newCompileError(output []byte) *revel.Error {
errorMatch = regexp.MustCompile(`(?m)^(.*?)\:(\d+)\:\s(.*?)$`).FindSubmatch(output) errorMatch = regexp.MustCompile(`(?m)^(.*?)\:(\d+)\:\s(.*?)$`).FindSubmatch(output)
if errorMatch == nil { if errorMatch == nil {
revel.ERROR.Println("Failed to parse build errors:\n", string(output)) revel.RevelLog.Error("Failed to parse build errors", "error", string(output))
return &revel.Error{ return &revel.Error{
SourceType: "Go code", SourceType: "Go code",
Title: "Go Compilation Error", Title: "Go Compilation Error",
@@ -333,7 +333,7 @@ func newCompileError(output []byte) *revel.Error {
errorMatch = append(errorMatch, errorMatch[3]) errorMatch = append(errorMatch, errorMatch[3])
revel.ERROR.Println("Build errors:\n", string(output)) revel.RevelLog.Error("Build errors", "errors", string(output))
} }
// Read the source for the offending file. // Read the source for the offending file.
@@ -360,7 +360,7 @@ func newCompileError(output []byte) *revel.Error {
fileStr, err := revel.ReadLines(absFilename) fileStr, err := revel.ReadLines(absFilename)
if err != nil { if err != nil {
compileError.MetaError = absFilename + ": " + err.Error() compileError.MetaError = absFilename + ": " + err.Error()
revel.ERROR.Println(compileError.MetaError) revel.RevelLog.Error(compileError.MetaError)
return compileError return compileError
} }

View File

@@ -97,7 +97,7 @@ func NewHarness() *Harness {
revel.MainTemplateLoader = revel.NewTemplateLoader( revel.MainTemplateLoader = revel.NewTemplateLoader(
[]string{filepath.Join(revel.RevelPath, "templates")}) []string{filepath.Join(revel.RevelPath, "templates")})
if err := revel.MainTemplateLoader.Refresh(); err != nil { if err := revel.MainTemplateLoader.Refresh(); err != nil {
revel.ERROR.Println(err) revel.RevelLog.Error("Template loader error", "error", err)
} }
addr := revel.HTTPAddr addr := revel.HTTPAddr
@@ -118,7 +118,7 @@ func NewHarness() *Harness {
serverURL, _ := url.ParseRequestURI(fmt.Sprintf(scheme+"://%s:%d", addr, port)) serverURL, _ := url.ParseRequestURI(fmt.Sprintf(scheme+"://%s:%d", addr, port))
harness := &Harness{ serverHarness := &Harness{
port: port, port: port,
serverHost: serverURL.String()[len(scheme+"://"):], serverHost: serverURL.String()[len(scheme+"://"):],
proxy: httputil.NewSingleHostReverseProxy(serverURL), proxy: httputil.NewSingleHostReverseProxy(serverURL),
@@ -126,11 +126,11 @@ func NewHarness() *Harness {
} }
if revel.HTTPSsl { if revel.HTTPSsl {
harness.proxy.Transport = &http.Transport{ serverHarness.proxy.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
} }
} }
return harness return serverHarness
} }
// Refresh method rebuilds the Revel application and run it on the given port. // Refresh method rebuilds the Revel application and run it on the given port.
@@ -143,7 +143,7 @@ func (h *Harness) Refresh() (err *revel.Error) {
h.app.Kill() h.app.Kill()
} }
revel.TRACE.Println("Rebuild") revel.RevelLog.Debug("Rebuild Called")
h.app, err = Build() h.app, err = Build()
if err != nil { if err != nil {
return return
@@ -187,7 +187,7 @@ func (h *Harness) Run() {
go func() { go func() {
addr := fmt.Sprintf("%s:%d", revel.HTTPAddr, revel.HTTPPort) addr := fmt.Sprintf("%s:%d", revel.HTTPAddr, revel.HTTPPort)
revel.INFO.Printf("Listening on %s", addr) revel.RevelLog.Infof("Listening on %s", addr)
var err error var err error
if revel.HTTPSsl { if revel.HTTPSsl {
@@ -200,7 +200,7 @@ func (h *Harness) Run() {
err = http.ListenAndServe(addr, h) err = http.ListenAndServe(addr, h)
} }
if err != nil { if err != nil {
revel.ERROR.Fatalln("Failed to start reverse proxy:", err) revel.RevelLog.Error("Failed to start reverse proxy:", "error", err)
} }
}() }()
@@ -218,13 +218,13 @@ func (h *Harness) Run() {
func getFreePort() (port int) { func getFreePort() (port int) {
conn, err := net.Listen("tcp", ":0") conn, err := net.Listen("tcp", ":0")
if err != nil { if err != nil {
revel.ERROR.Fatal(err) revel.RevelLog.Fatal("Unable to fetch a freee port address", "error", err)
} }
port = conn.Addr().(*net.TCPAddr).Port port = conn.Addr().(*net.TCPAddr).Port
err = conn.Close() err = conn.Close()
if err != nil { if err != nil {
revel.ERROR.Fatal(err) revel.RevelLog.Fatal("Unable to close port", "error", err)
} }
return port return port
} }
@@ -246,7 +246,7 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host string) {
} }
if err != nil { if err != nil {
http.Error(w, "Error contacting backend server.", 500) http.Error(w, "Error contacting backend server.", 500)
revel.ERROR.Printf("Error dialing websocket backend %s: %v", host, err) revel.RevelLog.Error("Error dialing websocket backend ", "host", host, "error", err)
return return
} }
hj, ok := w.(http.Hijacker) hj, ok := w.(http.Hijacker)
@@ -256,21 +256,21 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host string) {
} }
nc, _, err := hj.Hijack() nc, _, err := hj.Hijack()
if err != nil { if err != nil {
revel.ERROR.Printf("Hijack error: %v", err) revel.RevelLog.Error("Hijack error", "error", err)
return return
} }
defer func() { defer func() {
if err = nc.Close(); err != nil { if err = nc.Close(); err != nil {
revel.ERROR.Println(err) revel.RevelLog.Error("Connection close error", "error", err)
} }
if err = d.Close(); err != nil { if err = d.Close(); err != nil {
revel.ERROR.Println(err) revel.RevelLog.Error("Dial close error", "error", err)
} }
}() }()
err = r.Write(d) err = r.Write(d)
if err != nil { if err != nil {
revel.ERROR.Printf("Error copying request to target: %v", err) revel.RevelLog.Error("Error copying request to target", "error", err)
return return
} }

View File

@@ -13,7 +13,6 @@ import (
"go/parser" "go/parser"
"go/scanner" "go/scanner"
"go/token" "go/token"
"log"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@@ -98,14 +97,14 @@ func ProcessSource(roots []string) (*SourceInfo, *revel.Error) {
for _, root := range roots { for _, root := range roots {
rootImportPath := importPathFromPath(root) rootImportPath := importPathFromPath(root)
if rootImportPath == "" { if rootImportPath == "" {
revel.WARN.Println("Skipping code path", root) revel.RevelLog.Warn("Skipping empty code path", "path", root)
continue continue
} }
// Start walking the directory tree. // Start walking the directory tree.
_ = revel.Walk(root, func(path string, info os.FileInfo, err error) error { _ = revel.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
log.Println("Error scanning app source:", err) revel.RevelLog.Error("Error scanning app source:", "error", err)
return nil return nil
} }
@@ -149,7 +148,7 @@ func ProcessSource(roots []string) (*SourceInfo, *revel.Error) {
// This is exception, err alredy checked above. Here just a print // This is exception, err alredy checked above. Here just a print
ast.Print(nil, err) ast.Print(nil, err)
log.Fatalf("Failed to parse dir: %s", err) revel.RevelLog.Fatal("Failed to parse dir", "error", err)
} }
// Skip "main" packages. // Skip "main" packages.
@@ -174,7 +173,7 @@ func ProcessSource(roots []string) (*SourceInfo, *revel.Error) {
for i := range pkgs { for i := range pkgs {
println("Found package ", i) println("Found package ", i)
} }
log.Println("Most unexpected! Multiple packages in a single directory:", pkgs) revel.RevelLog.Error("Most unexpected! Multiple packages in a single directory:", "packages", pkgs)
} }
var pkg *ast.Package var pkg *ast.Package
@@ -199,7 +198,7 @@ func appendSourceInfo(srcInfo1, srcInfo2 *SourceInfo) *SourceInfo {
srcInfo1.InitImportPaths = append(srcInfo1.InitImportPaths, srcInfo2.InitImportPaths...) srcInfo1.InitImportPaths = append(srcInfo1.InitImportPaths, srcInfo2.InitImportPaths...)
for k, v := range srcInfo2.ValidationKeys { for k, v := range srcInfo2.ValidationKeys {
if _, ok := srcInfo1.ValidationKeys[k]; ok { if _, ok := srcInfo1.ValidationKeys[k]; ok {
log.Println("Key conflict when scanning validation calls:", k) revel.RevelLog.Warn("Key conflict when scanning validation calls:", "key", k)
continue continue
} }
srcInfo1.ValidationKeys[k] = v srcInfo1.ValidationKeys[k] = v
@@ -317,7 +316,7 @@ func addImports(imports map[string]string, decl ast.Decl, srcDir string) {
// We expect this to happen for apps using reverse routing (since we // We expect this to happen for apps using reverse routing (since we
// have not yet generated the routes). Don't log that. // have not yet generated the routes). Don't log that.
if !strings.HasSuffix(fullPath, "/app/routes") { if !strings.HasSuffix(fullPath, "/app/routes") {
revel.TRACE.Println("Could not find import:", fullPath) revel.RevelLog.Debug("Could not find import:", "path", fullPath)
} }
continue continue
} }
@@ -395,7 +394,7 @@ func appendStruct(specs []*TypeInfo, pkgImportPath string, pkg *ast.Package, dec
} else { } else {
var ok bool var ok bool
if importPath, ok = imports[pkgName]; !ok { if importPath, ok = imports[pkgName]; !ok {
log.Print("Failed to find import path for ", pkgName, ".", typeName) revel.RevelLog.Error("Failed to find import path for ", "package", pkgName, "type", typeName)
continue continue
} }
} }
@@ -454,13 +453,13 @@ func appendAction(fset *token.FileSet, mm methodMap, decl ast.Decl, pkgImportPat
var importPath string var importPath string
typeExpr := NewTypeExpr(pkgName, field.Type) typeExpr := NewTypeExpr(pkgName, field.Type)
if !typeExpr.Valid { if !typeExpr.Valid {
log.Printf("Didn't understand argument '%s' of action %s. Ignoring.\n", name, getFuncName(funcDecl)) revel.RevelLog.Warnf("Didn't understand argument '%s' of action %s. Ignoring.", name, getFuncName(funcDecl))
return // We didn't understand one of the args. Ignore this action. return // We didn't understand one of the args. Ignore this action.
} }
if typeExpr.PkgName != "" { if typeExpr.PkgName != "" {
var ok bool var ok bool
if importPath, ok = imports[typeExpr.PkgName]; !ok { if importPath, ok = imports[typeExpr.PkgName]; !ok {
log.Println("Failed to find import for arg of type:", typeExpr.TypeName("")) revel.RevelLog.Errorf("Failed to find import for arg of type:", typeExpr.TypeName(""))
} }
} }
method.Args = append(method.Args, &MethodArg{ method.Args = append(method.Args, &MethodArg{
@@ -646,7 +645,7 @@ func getStructTypeDecl(decl ast.Decl, fset *token.FileSet) (spec *ast.TypeSpec,
} }
if len(genDecl.Specs) == 0 { if len(genDecl.Specs) == 0 {
revel.WARN.Printf("Surprising: %s:%d Decl contains no specifications", fset.Position(decl.Pos()).Filename, fset.Position(decl.Pos()).Line) revel.RevelLog.Warnf("Surprising: %s:%d Decl contains no specifications", fset.Position(decl.Pos()).Filename, fset.Position(decl.Pos()).Line)
return return
} }
@@ -751,7 +750,7 @@ func NewTypeExpr(pkgName string, expr ast.Expr) TypeExpr {
e := NewTypeExpr(pkgName, t.Elt) e := NewTypeExpr(pkgName, t.Elt)
return TypeExpr{"[]" + e.Expr, e.PkgName, e.pkgIndex + 2, e.Valid} return TypeExpr{"[]" + e.Expr, e.PkgName, e.pkgIndex + 2, e.Valid}
default: default:
log.Println("Failed to generate name for field. Make sure the field name is valid.") revel.RevelLog.Error("Failed to generate name for field. Make sure the field name is valid.")
} }
return TypeExpr{Valid: false} return TypeExpr{Valid: false}
} }
@@ -799,10 +798,10 @@ func importPathFromPath(root string) string {
srcPath := filepath.Join(build.Default.GOROOT, "src", "pkg") srcPath := filepath.Join(build.Default.GOROOT, "src", "pkg")
if strings.HasPrefix(root, srcPath) { if strings.HasPrefix(root, srcPath) {
revel.WARN.Println("Code path should be in GOPATH, but is in GOROOT:", root) revel.RevelLog.Warn("Code path should be in GOPATH, but is in GOROOT:", "path", root)
return filepath.ToSlash(root[len(srcPath)+1:]) return filepath.ToSlash(root[len(srcPath)+1:])
} }
revel.ERROR.Println("Unexpected! Code path is not in GOPATH:", root) revel.RevelLog.Error("Unexpected! Code path is not in GOPATH:", "path", root)
return "" return ""
} }

View File

@@ -8,8 +8,6 @@ import (
"go/ast" "go/ast"
"go/parser" "go/parser"
"go/token" "go/token"
"io/ioutil"
"log"
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
@@ -183,7 +181,7 @@ NEXT_TEST:
func BenchmarkProcessBookingSource(b *testing.B) { func BenchmarkProcessBookingSource(b *testing.B) {
revel.Init("", "github.com/revel/examples/booking", "") revel.Init("", "github.com/revel/examples/booking", "")
revel.TRACE = log.New(ioutil.Discard, "", 0) revel.GetRootLogHandler().Disable()
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {

View File

@@ -60,11 +60,11 @@ func buildApp(args []string) {
} }
if err := os.RemoveAll(destPath); err != nil && !os.IsNotExist(err) { if err := os.RemoveAll(destPath); err != nil && !os.IsNotExist(err) {
revel.ERROR.Fatalln(err) revel.RevelLog.Fatal("Remove all error","error", err)
} }
if err := os.MkdirAll(destPath, 0777); err != nil { if err := os.MkdirAll(destPath, 0777); err != nil {
revel.ERROR.Fatalln(err) revel.RevelLog.Fatal("makedir error","error",err)
} }
app, reverr := harness.Build() app, reverr := harness.Build()
@@ -101,7 +101,7 @@ func buildApp(args []string) {
} }
modulePath, err := revel.ResolveImportPath(moduleImportPath) modulePath, err := revel.ResolveImportPath(moduleImportPath)
if err != nil { if err != nil {
revel.ERROR.Fatalln("Failed to load module %s: %s", key[len("module."):], err) revel.RevelLog.Fatalf("Failed to load module %s: %s", key[len("module."):], err)
} }
modulePaths[moduleImportPath] = modulePath modulePaths[moduleImportPath] = modulePath
} }

View File

@@ -8,7 +8,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"go/build" "go/build"
"log"
"math/rand" "math/rand"
"os" "os"
"os/exec" "os/exec"
@@ -67,8 +66,6 @@ func newApp(args []string) {
errorf("Too many arguments provided.\nRun 'revel help new' for usage.\n") errorf("Too many arguments provided.\nRun 'revel help new' for usage.\n")
} }
revel.ERROR.SetFlags(log.LstdFlags)
// checking and setting go paths // checking and setting go paths
initGoPaths() initGoPaths()
@@ -129,7 +126,7 @@ func initGoPaths() {
} }
if len(srcRoot) == 0 { if len(srcRoot) == 0 {
revel.ERROR.Fatalln("Abort: could not create a Revel application outside of GOPATH.") revel.RevelLog.Fatal("Abort: could not create a Revel application outside of GOPATH.")
} }
// set go src path // set go src path

View File

@@ -53,7 +53,7 @@ func packageApp(args []string) {
// Remove the archive if it already exists. // Remove the archive if it already exists.
destFile := filepath.Base(revel.BasePath) + ".tar.gz" destFile := filepath.Base(revel.BasePath) + ".tar.gz"
if err := os.Remove(destFile); err != nil && !os.IsNotExist(err) { if err := os.Remove(destFile); err != nil && !os.IsNotExist(err) {
revel.ERROR.Fatal(err) revel.RevelLog.Fatal("Unable to remove target file","error",err,"file",destFile)
} }
// Collect stuff in a temp directory. // Collect stuff in a temp directory.

View File

@@ -84,15 +84,6 @@ format.datetime = 2006-01-02 15:04
results.chunked = false results.chunked = false
# Prefixes for each log message line.
# User can override these prefix values within any section
# For e.g: [dev], [prod], etc
log.trace.prefix = "TRACE "
log.info.prefix = "INFO "
log.warn.prefix = "WARN "
log.error.prefix = "ERROR "
# The default language of this application. # The default language of this application.
i18n.default_language = en i18n.default_language = en
@@ -179,36 +170,12 @@ module.testrunner = github.com/revel/modules/testrunner
# Log to Os's standard error output. Default value. # Log to Os's standard error output. Default value.
# "relative/path/to/log" # "relative/path/to/log"
# Log to file. # Log to file.
log.trace.output = off log.all.filter.module.app = stdout # Log all loggers for the application to the stdout
log.info.output = stderr log.error.output = stderr # Log all loggers for Revel errors to the stderr
log.warn.output = stderr
log.error.output = stderr
# Revel log flags. Possible flags defined by the Go `log` package. Go log is
# "Bits OR'ed together to control what's printed
# See:
# https://golang.org/pkg/log/#pkg-constants
# Values:
# "0"
# Just log the message, turn off the flags.
# "3"
# log.LstdFlags (log.Ldate|log.Ltime)
# "19"
# log.Ldate|log.Ltime|log.Lshortfile
# "23"
# log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile
log.trace.flags = 19
log.info.flags = 19
log.warn.flags = 19
log.error.flags = 19
# Revel request access log # Revel request access log
# Access log line format: # Access log line format:
# RequestStartTime ClientIP ResponseStatus RequestLatency HTTPMethod URLPath # INFO 21:53:55 static server-engine.go:169: Request Stats ip=127.0.0.1 path=/public/vendors/datatables.net-buttons/js/buttons.html5.min.js method=GET start=2017/08/31 21:53:55 status=200 duration_seconds=0.0002583 section=requestlog
# Sample format:
# 2016/05/25 17:46:37.112 127.0.0.1 200 270.157µs GET /
log.request.output = stderr log.request.output = stderr
@@ -229,30 +196,12 @@ watch = false
module.testrunner = module.testrunner =
log.trace.output = off log.warn.output = log/%(app.name)s.log # Log all loggers for the application to the stdout
log.info.output = off log.error.output = log/%(app.name)s.log # Log all errors to the stdout
log.warn.output = log/%(app.name)s.log
log.error.output = log/%(app.name)s.log
# Revel log flags. Possible flags defined by the Go `log` package,
# please refer https://golang.org/pkg/log/#pkg-constants
# Go log is "Bits or'ed together to control what's printed"
# Examples:
# 0 => just log the message, turn off the flags
# 3 => log.LstdFlags (log.Ldate|log.Ltime)
# 19 => log.Ldate|log.Ltime|log.Lshortfile
# 23 => log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile
log.trace.flags = 3
log.info.flags = 3
log.warn.flags = 3
log.error.flags = 3
# Revel request access log # Revel request access log
# Access log line format: # Access log line format:
# RequestStartTime ClientIP ResponseStatus RequestLatency HTTPMethod URLPath # INFO 21:53:55 static server-engine.go:169: Request Stats ip=127.0.0.1 path=/public/vendors/datatables.net-buttons/js/buttons.html5.min.js method=GET start=2017/08/31 21:53:55 status=200 duration_seconds=0.0002583 section=requestlog
# Sample format:
# 2016/05/25 17:46:37.112 127.0.0.1 200 270.157µs GET /
# Example: # Example:
# log.request.output = %(app.name)s-request.log # log.request.output = %(app.name)s-request.json
log.request.output = off log.request.output = log/requests.json