本文整理汇总了Golang中github.com/ian-kent/go-log/log.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ParseCPANLines
func ParseCPANLines(lines []string) (*CPANFile, error) {
cpanfile := &CPANFile{}
for _, l := range lines {
if len(l) == 0 {
continue
}
log.Trace("Parsing line: %s", l)
dep, err := ParseCPANLine(l)
if err != nil {
log.Error("=> Error parsing line: %s", err)
continue
}
if dep != nil {
log.Info("=> Found dependency: %s", dep)
cpanfile.AddDependency(dep)
continue
}
log.Trace("=> No error and no dependency found")
}
log.Info("Found %d dependencies in cpanfile", len(cpanfile.Dependencies))
return cpanfile, nil
}
示例2: Listen
// Listen binds to httpBindAddr
func Listen(httpBindAddr string, Asset func(string) ([]byte, error), exitCh chan int, registerCallback func(http.Handler)) {
log.Info("[HTTP] Binding to address: %s", httpBindAddr)
pat := pat.New()
registerCallback(pat)
f := func(w http.ResponseWriter, req *http.Request) {
if Authorised == nil {
pat.ServeHTTP(w, req)
return
}
u, pw, ok := req.BasicAuth()
if !ok || !Authorised(u, pw) {
w.Header().Set("WWW-Authenticate", "Basic")
w.WriteHeader(401)
return
}
pat.ServeHTTP(w, req)
}
err := http.ListenAndServe(httpBindAddr, http.HandlerFunc(f))
if err != nil {
log.Fatalf("[HTTP] Error binding to address %s: %s", httpBindAddr, err)
}
}
示例3: loadBackPANSource
func (s *Source) loadBackPANSource() error {
log.Info("Loading BackPAN index: backpan-index")
file, err := os.Open("backpan-index")
if err != nil {
log.Warn(err.Error())
return nil
}
index, err := ioutil.ReadAll(file)
file.Close()
if err != nil {
log.Fatal(err)
}
for _, p := range strings.Split(string(index), "\n") {
if !strings.HasPrefix(p, "authors/id/") {
continue
}
//log.Printf("Parsing: %s\n", p)
m := s.ModuleFromBackPANIndex(p)
if m != nil {
s.ModuleList[m.Name+"-"+m.Version] = m
}
}
log.Printf("Found %d packages for source: %s", len(s.ModuleList), s)
return nil
}
示例4: ExecFunction
func (ws *Workspace) ExecFunction(task *Task, name string, args ...string) string {
log.Info("Executing function %s: %s", name, args)
var fn *Function
if f, ok := ws.Functions[name]; ok {
fn = f
} else if f, ok := GlobalWorkspace.Functions[name]; ok {
fn = f
} else {
log.Warn("Function not found: %s", name)
return ""
}
argmap := make(map[string]string)
for i, arg := range fn.Args {
argmap[arg] = args[i]
}
for k, v := range argmap {
log.Info("argmap: %s => %s", k, v)
for t, m := range task.Metadata {
log.Info("meta: %s => %s", t, m)
v = strings.Replace(v, "$"+t, m, -1)
}
argmap[k] = v
}
c := fn.Command
for k, v := range argmap {
log.Info("ARG: %s => %s", k, v)
c = strings.Replace(c, k, v, -1)
}
var funcEnvironment map[string]string
if ws.InheritEnvironment {
funcEnvironment = ws.Environment
} else if GlobalWorkspace.InheritEnvironment {
funcEnvironment = GlobalWorkspace.Environment
} else {
funcEnvironment = make(map[string]string)
}
tsk := NewTask(nil, "Function$"+name, fn.Executor, c, funcEnvironment, false, "", "", make(map[string]string), "")
ch := tsk.Start()
<-ch
return tsk.TaskRuns[0].StdoutBuf.String()
}
示例5: loadSessionData
func (s *Session) loadSessionData() {
if sid_cookie, ok := s.Request.Cookies["__SID"]; ok {
s.SessionID = sid_cookie.Value
log.Info("Retrieved session ID (__SID): %s", s.SessionID)
}
s.readSessionData()
}
示例6: PrintDeps
func (deps *DependencyList) PrintDeps(d int) {
for _, dep := range deps.Dependencies {
if dep.Module == nil {
log.Info(MkIndent(0)+"%s not found", dep.Name)
continue
}
dep.Module.PrintDeps(d + 1)
}
}
示例7: loadCPANSource
func (s *Source) loadCPANSource() error {
log.Info("Loading CPAN index: %s", s.Index)
res, err := http.Get(s.Index)
if err != nil {
log.Warn("Error loading index: %s", err)
return nil
}
// TODO optional gzip
r, err := gzip.NewReader(res.Body)
if err != nil {
log.Warn(err.Error())
b, _ := ioutil.ReadAll(res.Body)
log.Info("%s", string(b))
return nil
}
packages, err := ioutil.ReadAll(r)
res.Body.Close()
if err != nil {
log.Warn(err)
return nil
}
foundnl := false
for _, p := range strings.Split(string(packages), "\n") {
if !foundnl && len(p) == 0 {
foundnl = true
continue
}
if !foundnl || len(p) == 0 {
continue
}
m := s.ModuleFromCPANIndex(p)
s.ModuleList[m.Name] = m
}
log.Info("Found %d packages for source: %s", len(s.ModuleList), s)
return nil
}
示例8: createSessionId
func (r *Response) createSessionId() {
bytes := make([]byte, 256)
rand.Read(bytes)
s, _ := bcrypt.GenerateFromPassword(bytes, 11)
r.session.SessionID = string(s)
log.Info("Generated session ID (__SID): %s", r.session.SessionID)
r.Cookies.Set(&nethttp.Cookie{
Name: "__SID",
Value: r.session.SessionID,
Path: "/",
})
}
示例9: GetColumn
func (ws *Workspace) GetColumn(task *Task, name string) string {
log.Info("GetColumn: %s => %s", task.Name, name)
col := ws.Columns[name]
var fn []string
var nm string
for n, args := range col {
nm = n
fn = args
break
}
return ws.ExecFunction(task, nm, fn...)
}
示例10: LoadConfig
func LoadConfig(global string, workspaces []string) {
// Load global environment
log.Info("Loading global environment file: %s", global)
cfg, err := LoadConfigFile(global)
if err != nil {
log.Error("Error loading global configuration: %s", err.Error())
}
if cfg != nil {
GlobalConfigWorkspace = cfg
}
// Load workspaces
for _, conf := range workspaces {
log.Info("Loading workspace file: %s", conf)
cfg, err := LoadConfigFile(conf)
if err != nil {
log.Error("Error loading workspace: %s", err.Error())
}
if cfg != nil {
ConfigWorkspaces[cfg.Name] = cfg
}
}
}
示例11: readSessionData
func (s *Session) readSessionData() {
sd, ok := s.Request.Cookies["__SD"]
if ok && sd.Value != "" {
log.Info("Retrieved session data (__SD): %s", sd.Value)
sdata := make(map[string]string)
err := json.Unmarshal([]byte(fromBase64(sd.Value)), &sdata)
if err != nil {
s.RenderException(500, err)
return
}
s.SessionData = sdata
}
}
示例12: runLoop
func runLoop() {
conf, err := readConf()
AssertNoErr(err, "Failed to read config file")
log.Debug("Global conf: %#v", conf)
nif := conf["config"]["if"]
interval := atoi(conf["config"]["interval"], 5)
for name := range notifyOnChange(nif, interval) {
log.Info("Network changed: %s", name)
if section, ok := conf["ssid:"+name]; ok {
log.Debug("Found section: %v", section)
ApplyCmds(section)
} else {
log.Debug("Undefined section for: %s", name)
}
}
}
示例13: ParseCPANLine
func ParseCPANLine(line string) (*Dependency, error) {
if len(line) == 0 {
return nil, nil
}
matches := re.FindStringSubmatch(line)
if len(matches) == 0 {
log.Trace("Unable to parse line: %s", line)
return nil, nil
}
module := matches[2]
version := strings.Replace(matches[4], " ", "", -1)
comment := matches[5]
dependency, err := DependencyFromString(module, version)
if strings.HasPrefix(strings.Trim(comment, " "), "# REQS: ") {
comment = strings.TrimPrefix(strings.Trim(comment, " "), "# REQS: ")
log.Trace("Found additional dependencies: %s", comment)
for _, req := range strings.Split(comment, ";") {
req = strings.Trim(req, " ")
bits := strings.Split(req, "-")
new_dep, err := DependencyFromString(bits[0], bits[1])
if err != nil {
log.Error("Error parsing REQS dependency: %s", req)
continue
}
log.Trace("Added dependency: %s", new_dep)
dependency.Additional = append(dependency.Additional, new_dep)
}
}
if err != nil {
return nil, err
}
log.Info("%s (%s %s)", module, dependency.Modifier, dependency.Version)
return dependency, err
}
示例14: Find
func (s *Source) Find(d *Dependency) (*Module, error) {
log.Debug("Finding dependency: %s", d)
switch s.Type {
case "SmartPAN":
log.Debug("=> Using SmartPAN source")
url := s.URL
if !strings.HasSuffix(s.URL, "/") {
url += "/"
}
url += "where/" + d.Name + "/" + d.Modifier + d.Version
log.Info("Query: %s", url)
res, err := http.Get(url)
if err != nil {
log.Error("Error querying SmartPAN: %s", err.Error())
return nil, err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
log.Trace("Got response: %s", string(body))
if res.StatusCode != http.StatusOK {
log.Info("Module not found in SmartPAN: %s", d.Name)
return nil, nil
}
var v *WhereOutput
if err = json.Unmarshal(body, &v); err != nil {
log.Error("Error parsing JSON: %s", err.Error())
return nil, err
}
log.Trace("Found module %s", v.Module)
if len(v.Versions) == 0 {
log.Info("Found module but no versions returned")
return nil, nil
}
var lv *VersionOutput
for _, ver := range v.Versions {
if ver.Version == v.Latest {
log.Info("Using latest version of %s: %f", v.Module, ver.Version)
lv = ver
break
}
}
if lv == nil {
log.Info("Couldn't find latest version, selecting first available")
lv = v.Versions[0]
}
return &Module{
Name: d.Name,
Version: fmt.Sprintf("%f", lv.Version),
Source: s,
Url: lv.URL,
}, nil
case "CPAN":
log.Debug("=> Using CPAN source")
if mod, ok := s.ModuleList[d.Name]; ok {
log.Trace("=> Found in source: %s", mod)
if d.Matches(mod) {
log.Trace("=> Version (%s) matches dependency: %s", mod.Version, d)
return mod, nil
}
log.Trace("=> Version (%s) doesn't match dependency: %s", mod.Version, d)
return nil, nil
}
case "BackPAN":
log.Debug("=> Using BackPAN source")
// TODO better version matching - new backpan index?
if mod, ok := s.ModuleList[d.Name+"-"+d.Version]; ok {
log.Trace("=> Found in source: %s", mod)
if d.Matches(mod) {
log.Trace("=> Version (%s) matches dependency: %s", mod.Version, d)
return mod, nil
}
log.Trace("=> Version (%s) doesn't match dependency: %s", mod.Version, d)
return nil, nil
}
case "MetaCPAN":
log.Debug("=> Using MetaCPAN source")
var sout, serr bytes.Buffer
var cpanm_args string = fmt.Sprintf("-L %s --info %s~\"%s%s\"", config.InstallDir, d.Name, d.Modifier, d.Version)
cpanm_cache_dir, err := filepath.Abs(config.CacheDir)
if err != nil {
log.Error("Failed to get absolute path of gopan cache directory: %s", err)
return nil, err
}
log.Trace("About to exec: cpanm %s", cpanm_args)
os.Setenv("CPANM_INFO_ARGS", cpanm_args)
//.........这里部分代码省略.........
示例15: LoadIndex
func LoadIndex(index string) map[string]*Source {
indexes := make(map[string]*Source)
log.Info("Loading cached index file %s", index)
if _, err := os.Stat(index); err != nil {
log.Error("Cached index file not found")
return indexes
}
var bytes []byte
if strings.HasSuffix(index, ".gz") {
fi, err := os.Open(index)
if err != nil {
log.Error("Error reading index: %s", err.Error())
return indexes
}
defer fi.Close()
gz, err := gzip.NewReader(fi)
if err != nil {
log.Error("Error creating gzip reader: %s", err.Error())
return indexes
}
bytes, err = ioutil.ReadAll(gz)
if err != nil {
log.Error("Error reading from gzip: %s", err.Error())
return indexes
}
} else {
var err error
bytes, err = ioutil.ReadFile(index)
if err != nil {
log.Error("Error reading index: %s", err.Error())
return indexes
}
}
lines := strings.Split(string(bytes), "\n")
var csource *Source
var cauth *Author
var cpkg *Package
resrcauth := regexp.MustCompile("^\\s*(.*)\\s\\[(.*)\\]\\s*$")
repackage := regexp.MustCompile("^\\s*(.*)\\s=>\\s(.*)\\s*$")
reprovides := regexp.MustCompile("^\\s*(.*)\\s\\((.*)\\):\\s(.*)\\s*$")
for _, l := range lines {
log.Trace("Line: %s", l)
if strings.HasPrefix(l, " ") {
// provides
log.Trace("=> Provides")
match := reprovides.FindStringSubmatch(l)
if len(match) > 0 {
if strings.HasPrefix(match[1], "-") {
log.Trace(" - Is a removal")
match[1] = strings.TrimPrefix(match[1], "-")
if _, ok := cpkg.Provides[match[1]]; ok {
delete(cpkg.Provides, match[1])
}
if len(cpkg.Provides) == 0 {
delete(cauth.Packages, cpkg.Name)
cpkg = nil
}
if len(cauth.Packages) == 0 {
delete(csource.Authors, cauth.Name)
cauth = nil
}
if len(csource.Authors) == 0 {
delete(indexes, csource.Name)
csource = nil
}
} else {
cpkg.Provides[match[1]] = &PerlPackage{
Name: match[1],
Version: match[2],
Package: cpkg,
File: match[3],
}
}
}
} else if strings.HasPrefix(l, " ") {
// its a package
log.Trace("=> Package")
match := repackage.FindStringSubmatch(l)
if len(match) > 0 {
if strings.HasPrefix(match[1], "-") {
log.Trace(" - Is a removal")
match[1] = strings.TrimPrefix(match[1], "-")
if _, ok := cauth.Packages[match[1]]; ok {
delete(cauth.Packages, match[1])
}
if len(cauth.Packages) == 0 {
delete(csource.Authors, cauth.Name)
cauth = nil
}
if len(csource.Authors) == 0 {
delete(indexes, csource.Name)
csource = nil
}
} else {
if _, ok := cauth.Packages[match[1]]; ok {
//.........这里部分代码省略.........