本文整理汇总了Golang中github.com/gsdocker/gslogger.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewCodeGen
// NewCodeGen .
func NewCodeGen(rootpath string, skips []string) (gslang.Visitor, error) {
codeGen := &_CodeGen{
Log: gslogger.Get("gen4go"),
rootpath: rootpath,
prefix: make(map[string]string),
}
for _, skip := range skips {
exp, err := regexp.Compile(skip)
if err != nil {
return nil, gserrors.Newf(err, "invalid skip regex string :%s", skip)
}
codeGen.skips = append(codeGen.skips, exp)
}
funcs := template.FuncMap{
"title": codeGen.title,
"title2": strings.Title,
"enumFields": codeGen.enumFields,
"typeName": codeGen.typeName,
"enumRead": codeGen.enumRead,
"enumWrite": codeGen.enumWrite,
"fieldDecl": codeGen.fieldDecl,
"defaultVal": codeGen.defaultVal,
"marshalField": codeGen.marshalField,
"unmarshalField": codeGen.unmarshalField,
"methodDecl": codeGen.methodDecl,
"rpcMethodDecl": codeGen.rpcMethodDecl,
"unmarshalParam": codeGen.unmarshalParam,
"marshalParam": codeGen.marshalParam,
"methodCall": codeGen.methodCall,
"marshalReturn": codeGen.marshalReturn,
"unmarshalReturn": codeGen.unmarshalReturn,
"notVoid": gslang.NotVoid,
"isPOD": gslang.IsPOD,
"isAsync": gslang.IsAsync,
"isException": gslang.IsException,
"enumSize": gslang.EnumSize,
"enumType": func(typeDecl ast.Type) string {
return builtin[gslang.EnumType(typeDecl)]
},
"builtin": gslang.IsBuiltin,
"marshalParams": codeGen.marshalParams,
"callback": codeGen.callback,
"tagValue": codeGen.tagValue,
}
tpl, err := template.New("t4objc").Funcs(funcs).Parse(t4objc)
if err != nil {
return nil, err
}
codeGen.tpl = tpl
return codeGen, nil
}
示例2: newContext
func newContext(name string, handler Handler, pipeline *_Pipeline, prev *_Context) (*_Context, error) {
context := &_Context{
Log: gslogger.Get("handler-context"),
name: name,
handler: handler,
pipeline: pipeline,
prev: prev,
state: handlerUnregister,
}
context.shared, _ = handler.(SharedHandler)
err := context.handler.Register(context)
if err != nil {
return nil, err
}
if context.prev != nil {
context.prev.next = context
}
context.state = handlerRegister
return context, nil
}
示例3: Open
// Open create new tsdb with root directory
func Open(filepath string) (DataSource, error) {
if !fs.Exists(filepath) {
err := os.MkdirAll(filepath, 0644)
if err != nil {
return nil, err
}
}
idgen, err := newSEQIDGen(filepath)
if err != nil {
return nil, err
}
persistence, err := newDB(filepath)
if err != nil {
return nil, err
}
return &_DataSource{
Log: gslogger.Get("tsdb"),
SEQIDGen: idgen,
Persistence: persistence,
cached: make(map[string]*_Cached),
cachedsize: gsconfig.Int("tsdb.cached.size", 1024),
}, nil
}
示例4: newClientHandler
func (proxy *_Proxy) newClientHandler() gorpc.Handler {
return &_Client{
Log: gslogger.Get("gsproxy-client"),
context: proxy,
}
}
示例5: Visit
// Visit visit ast tree
func (compiler *Compiler) Visit(codeGen Visitor) (err error) {
defer func() {
if e := recover(); e != nil {
gserr, ok := e.(gserrors.GSError)
if ok {
err = gserr
} else {
err = gserrors.Newf(e.(error), "catch unknown error")
}
}
}()
gen := &_Visitor{
Log: gslogger.Get("codegen"),
codeGen: codeGen,
module: compiler.module,
compiler: compiler,
}
gen.visit()
return
}
示例6: Build
// Build create new Pipeline
func (builder *PipelineBuilder) Build(name string) (Pipeline, error) {
pipeline := &_Pipeline{
Log: gslogger.Get("pipeline"),
name: name,
timewheel: builder.timewheel,
sendcached: make(chan func() (*Message, error), builder.cachedsize),
closedflag: make(chan bool),
}
close(pipeline.closedflag)
pipeline.Sink = NewSink(name, pipeline, pipeline.TimeWheel(), builder.timeout)
var err error
for i, f := range builder.handlers {
pipeline.tail, err = newContext(builder.names[i], f(), pipeline, pipeline.tail)
if pipeline.header == nil {
pipeline.header = pipeline.tail
}
if err != nil {
return nil, err
}
}
return pipeline, err
}
示例7: NewHeartbeatHandler
// NewHeartbeatHandler create new heartbeat handler
func NewHeartbeatHandler(timeout time.Duration) gorpc.Handler {
return &_HeartbeatHandler{
Log: gslogger.Get("heartbeat"),
timeout: timeout,
timestamp: time.Now(),
}
}
示例8: New
// New create new gsdocker runner
func New(name string) Runner {
runner := &_Runner{
Log: gslogger.Get(name),
flagString: make(map[string]*string),
flagInt: make(map[string]*int64),
flagUint: make(map[string]*uint64),
flagFloat32: make(map[string]*float64),
flagFloat64: make(map[string]*float64),
flagSecond: make(map[string]*uint64),
flagMilliseconds: make(map[string]*uint64),
fullname: make(map[string]string),
}
runner.FlagString(
"log", "gsrunner.log", "", "the gsrunner log root path",
).FlagString(
"level", "gsrunner.log.level", "", "the gsrunner log level",
).FlagString(
"pprof", "gsrunner.pprof", "", "set gsrunner pprof listen address",
).FlagString(
"config", "gsrunner.config", "", "set gsrunner config file",
).FlagString(
"registry", "gsrunner.registry", "", "set the rpc services registry file",
)
return runner
}
示例9: newEval
func newEval(errorHandler ErrorHandler, module *ast.Module) Eval {
return &_Eval{
Log: gslogger.Get("eval"),
module: module,
errorHandler: errorHandler,
}
}
示例10: NewCryptoClient
// NewCryptoClient .
func NewCryptoClient(device *gorpc.Device, dhKey *DHKey) gorpc.Handler {
return &_CryptoClient{
Log: gslogger.Get("crpyto-client"),
dhKey: dhKey,
device: device,
}
}
示例11: newTunnelServer
func (proxy *_Proxy) newTunnelServer() gorpc.Handler {
return &_TunnelServerHandler{
Log: gslogger.Get("agent-server-tunnel"),
proxy: proxy,
id: proxy.tunnelID(),
}
}
示例12: newTunnelClient
func (system *_System) newTunnelClient(name string) gorpc.Handler {
return &_TunnelClient{
Log: gslogger.Get("gsagent-tunnel"),
name: name,
system: system,
timeout: system.timeout,
}
}
示例13: NewAcceptor
// NewAcceptor create new server channel acceptor
func NewAcceptor(name string, builder *PipelineBuilder) *Acceptor {
return &Acceptor{
Log: gslogger.Get(name),
builder: builder,
timeout: gsconfig.Seconds("timeout", 5),
name: name,
}
}
示例14: newTransProxyHandler
func (proxy *_Proxy) newTransProxyHandler() gorpc.Handler {
return &_TransProxyHandler{
Log: gslogger.Get("trans-proxy"),
proxy: proxy,
servers: make(map[uint16]Server),
tunnels: make(map[byte]Server),
}
}
示例15: main
func main() {
gslogger.Console("$content", "2006-01-02 15:04:05.999999")
gslogger.NewFlags(gslogger.ERROR | gslogger.WARN | gslogger.INFO)
log := gslogger.Get("gsrpc")
defer func() {
if e := recover(); e != nil {
log.E("%s", e)
}
gslogger.Join()
}()
flag.Parse()
*output, _ = filepath.Abs(*output)
log.I("Start gsRPC With Target Language(%s)", *lang)
codegenF, ok := langs[*lang]
if !ok {
log.E("unknown gsrpc object language :%s", *lang)
os.Exit(1)
}
codegen, err := codegenF(*output, []string{"github.com/gsrpc/gslang"})
if err != nil {
gserrors.Panicf(err, "create language(%s) codegen error", *lang)
}
compiler := gslang.NewCompiler("gsrpc", gslang.HandleError(func(err *gslang.Error) {
gserrors.Panicf(err.Orignal, "parse %s error\n\t%s", err.Start, err.Text)
}))
for _, file := range flag.Args() {
log.I("Compile gsLang File :%s", file)
if err := compiler.Compile(file); err != nil {
gserrors.Panicf(err, "compile %s error", file)
}
}
log.I("Link ...")
err = compiler.Link()
if err != nil {
gserrors.Panicf(err, "link error")
}
log.I("Output Directory :%s", *output)
if err := compiler.Visit(codegen); err != nil {
gserrors.Panicf(err, "generate language codes(%s) error", *lang)
}
log.I("Run gsRPC Compile -- Success")
}