Skip to content

Commit

Permalink
optimization logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vipally committed Sep 23, 2016
1 parent 0d584b1 commit 2933303
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions gpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ func Version() string {
return version
}

func relatePath(full string) string {
return strings.TrimPrefix(full, goPath)
}

//main func of gogp
func Work(dir string) (nGpg, nGp int, err error) {

fmt.Printf("Processing path:[%s]\n", dir)
dir = strings.Replace(dir, "\\", "/", -1)
fmt.Printf("Working at:[%s]\n", relatePath(dir))
files, e := collect_sub_files(dir, g_gpg_ext)
if e != nil {
err = e
Expand All @@ -86,7 +90,7 @@ func Work(dir string) (nGpg, nGp int, err error) {
}

func gen_gp_code_by_gpg(path_with_name string) (nGen int, err error) {
fmt.Printf("Processing:%s\n", path_with_name)
fmt.Printf(" Processing:%s\n", relatePath(path_with_name))
gpg_file := path_with_name + g_gpg_ext
if ini, err := ini.New(gpg_file); err == nil {
gpg_imps := ini.Sections()
Expand All @@ -96,7 +100,7 @@ func gen_gp_code_by_gpg(path_with_name string) (nGen int, err error) {
for _, gp_reg_src := range gp_reg_srcs {
replace := ini.GetString(gpg_imp, gp_reg_src, "")
if replace == "" {
fmt.Println("[Warn:]", gpg_file, gpg_imp, gp_reg_src, "has no replace string")
fmt.Println(" [Warn:]", relatePath(gpg_file), gpg_imp, gp_reg_src, "has no replace string")
}
match := fmt.Sprintf(g_gp_fmt, gp_reg_src)
g_map_rep[match] = replace
Expand All @@ -107,17 +111,17 @@ func gen_gp_code_by_gpg(path_with_name string) (nGen int, err error) {
panic(err)
}
}
fmt.Printf("%s finish gen %d file(s)\n", path_with_name, nGen)
}
return
}

func gen_gp_code_by_gp(path_with_name string, imp_name string) (err error) {
var fin, fout *os.File
var gpFilePath = path_with_name
fmt.Println("gen_gp_code_by_gp", path_with_name, imp_name)
//fmt.Println("gen_gp_code_by_gp", relatePath(path_with_name), imp_name)
if gp, ok := g_map_rep[keyGpFileDir]; ok { //read gp file from another path
gpFilePath = goPath + gp
gpFilePath = strings.Replace(gpFilePath, "\\", "/", -1)
}
gp_file := gpFilePath + g_gp_ext
if fin, err = os.Open(gp_file); err != nil {
Expand Down Expand Up @@ -155,10 +159,11 @@ func gen_gp_code_by_gp(path_with_name string, imp_name string) (err error) {
return
}
if g_match_no_rep {
s := fmt.Sprintf("error:[%s].[%s] not every gp have been replaced\n", path_with_name, imp_name)
s := fmt.Sprintf("error:[%s].[%s] not every gp have been replaced\n", relatePath(path_with_name), imp_name)
fmt.Println(s)
err = fmt.Errorf(s)
}
fmt.Printf(" [%s] finish\n", relatePath(code_file))
return
}

Expand Down

0 comments on commit 2933303

Please sign in to comment.