Implementing the new logging infrastructure

Moved logging to the new logging infrastructure by removing the use of
ColorLog() function. Added more documentation. Also fixed some typos in
comments and function names.
This commit is contained in:
Faissal Elamraoui
2016-11-13 15:14:48 +01:00
parent 0e54238559
commit cf7aef47f0
26 changed files with 421 additions and 525 deletions

View File

@ -35,19 +35,17 @@ func generateModel(mname, fields, currpath string) {
modelStruct, hastime, err := getStruct(modelName, fields)
if err != nil {
ColorLog("[ERRO] Could not generate the model struct: %s\n", err)
os.Exit(2)
logger.Fatalf("Could not generate the model struct: %s", err)
}
ColorLog("[INFO] Using '%s' as model name\n", modelName)
ColorLog("[INFO] Using '%s' as package name\n", packageName)
logger.Infof("Using '%s' as model name", modelName)
logger.Infof("Using '%s' as package name", packageName)
fp := path.Join(currpath, "models", p)
if _, err := os.Stat(fp); os.IsNotExist(err) {
// Create the model's directory
if err := os.MkdirAll(fp, 0777); err != nil {
ColorLog("[ERRO] Could not create the model directory: %s\n", err)
os.Exit(2)
logger.Fatalf("Could not create the model directory: %s", err)
}
}
@ -67,8 +65,7 @@ func generateModel(mname, fields, currpath string) {
formatSourceCode(fpath)
fmt.Fprintf(w, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", fpath, "\x1b[0m")
} else {
ColorLog("[ERRO] Could not create model file: %s\n", err)
os.Exit(2)
logger.Fatalf("Could not create model file: %s", err)
}
}