How to use getLogConfig method of service Package

Best Selenoid code snippet using service.getLogConfig

grpc_test.go

Source:grpc_test.go Github

copy

Full Screen

1package air_grpc2import (3 "context"4 airetcd "github.com/airingone/air-etcd"5 "github.com/airingone/config"6 "github.com/airingone/log"7 "github.com/airingone/pro_proto/helloword"8 "google.golang.org/grpc"9 "google.golang.org/grpc/balancer/roundrobin"10 "google.golang.org/grpc/resolver"11 "net"12 "testing"13 "time"14)15//protoc --go_out=plugins=grpc:. helloword.proro16//sever17func TestGrpcServer(t *testing.T) {18 config.InitConfig() //配置文件初始化19 log.InitLog(config.GetLogConfig("log")) //日志初始化20 airetcd.RegisterLocalServerToEtcd(config.GetString("server.name"),21 config.GetUInt32("server.port"), config.GetStringSlice("etcd.addrs")) //将服务注册到etcd集群22 listen, err := net.Listen("tcp", ":"+config.GetString("server.port"))23 if err != nil {24 log.Fatal("[GRPC]: TestGrpcServer listen failed, %+v", err)25 }26 server := grpc.NewServer()27 helloword.RegisterGreeterServer(server, &Server{})28 server.Serve(listen)29}30type Server struct {31}32//服务实现33func (s *Server) SayHello(ctx context.Context, in *helloword.HelloRequest) (*helloword.HelloReply, error) {34 c := NewGrpcContext(ctx, "1234567") //需要在请求包带requestid35 result := hello(c, in.Name)36 return &helloword.HelloReply{Message: result}, nil37}38func hello(ctx *GrpcContext, name string) string {39 ctx.LogHandler.Logger.Info("hello process succ")40 return "Hello" + name41}42//请求43func TestGrpcClient(t *testing.T) {44 config.InitConfig() //配置文件初始化45 log.InitLog(config.GetLogConfig("log")) //日志初始化46 //每个服务全局注册一次47 etcdConfig := config.GetGrpcConfig("grpc_test")48 r := airetcd.NewGrpcResolver(config.GetEtcdConfig("etcd").Addrs)49 resolver.Register(r)50 //conn初始化一次即可,grpc会维护连接51 ctx, _ := context.WithTimeout(context.Background(), time.Duration(etcdConfig.TimeOutMs)*time.Millisecond)52 conn, err := grpc.DialContext(ctx, etcdConfig.Name, //obejct会传给etcd作为watch对象53 grpc.WithInsecure(),54 grpc.WithDefaultServiceConfig(roundrobin.Name),55 grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin":{}}]}`),56 grpc.WithBlock())57 defer conn.Close()58 req := &helloword.HelloRequest{59 Name: "test",60 }61 c := helloword.NewGreeterClient(conn)62 rsp, err := c.SayHello(context.Background(), req)63 if err != nil {64 log.Error("[GRPC]: SayHello Err, %v", err)65 return66 }67 log.Error("[GRPC]: rsp:%+v", rsp)68}...

Full Screen

Full Screen

sip_service.go

Source:sip_service.go Github

copy

Full Screen

1package pjgo2import (3 "fmt"4 "github.com/Gorynychdo/pjgo/internal/pkg/pjsua2"5 "sync"6 "time"7)8type SipService struct {9 endpoint pjsua2.Endpoint10 account pjsua2.Account11 call pjsua2.Call12 config *Config13}14var (15 mutex sync.Mutex16 logWriter = pjsua2.NewDirectorLogWriter(new(SipLogWriter))17)18func NewSipService(config *Config) *SipService {19 sipService := SipService{20 config: config,21 }22 sipService.init()23 return &sipService24}25func (ss *SipService) init() {26 ss.endpoint = pjsua2.NewEndpoint()27 ss.endpoint.LibCreate()28 epConfig := pjsua2.NewEpConfig()29 epConfig.GetLogConfig().SetLevel(ss.config.LogLevel)30 epConfig.GetLogConfig().SetWriter(logWriter)31 ss.endpoint.LibInit(epConfig)32 ss.endpoint.AudDevManager().SetNullDev()33 ss.endpoint.TransportCreate(pjsua2.PJSIP_TRANSPORT_UDP, pjsua2.NewTransportConfig())34 ss.endpoint.LibStart()35 fmt.Printf("[ SipService ] Available codecs:\n")36 for i := 0; i < int(ss.endpoint.CodecEnum().Size()); i++ {37 c := ss.endpoint.CodecEnum().Get(i)38 fmt.Printf("\t - %s (priority: %d)\n", c.GetCodecId(), c.GetPriority())39 }40 fmt.Printf("[ SipService ] PJSUA2 STARTED ***\n")41}42func (ss *SipService) RegisterAccount() {43 ss.checkThread()44 fmt.Printf("[ SipService ] Registration start, user=%v\n", ss.config.Login)45 ss.account = pjsua2.NewDirectorAccount(NewSipAccount(ss.config.Login, ss))46 accountConfig := pjsua2.NewAccountConfig()47 accountConfig.SetIdUri(ss.config.Id)48 accountConfig.GetRegConfig().SetRegistrarUri(ss.config.Uri)49 cred := pjsua2.NewAuthCredInfo("digest", "*", ss.config.Login, 0, ss.config.Password)50 accountConfig.GetSipConfig().GetAuthCreds().Add(cred)51 ss.account.Create(accountConfig)52 fmt.Printf("[ SipService ] Account Created, URI = %v\n", ss.account.GetInfo().GetUri())53}54func (ss *SipService) MakeCall(remoteUri string) {55 ss.checkThread()56 sipCall := NewSipCall(ss)57 ss.call = pjsua2.NewDirectorCall(sipCall, ss.account)58 sipCall.call = ss.call59 callOpParam := pjsua2.NewCallOpParam(true)60 callOpParam.GetOpt().SetAudioCount(1)61 ss.call.MakeCall(remoteUri, callOpParam)62 ci := ss.call.GetInfo()63 fmt.Printf("[ SipService ] Make Call, From = %v, To = %v, callId = %v\n",64 ss.account.GetInfo().GetUri(), remoteUri, ci.GetCallIdString())65}66func (ss *SipService) Shutdown() {67 ss.checkThread()68 ss.endpoint.HangupAllCalls()69 time.Sleep(time.Second)70 ss.checkThread()71 ss.account.Shutdown()72 ss.endpoint.LibDestroy()73}74func (ss *SipService) checkThread() {75 mutex.Lock()76 defer mutex.Unlock()77 if !ss.endpoint.LibIsThreadRegistered() {78 ss.endpoint.LibRegisterThread("")79 }80}...

Full Screen

Full Screen

configer.go

Source:configer.go Github

copy

Full Screen

1package hdsdk2import (3 "github.com/hdget/hdsdk/types"4)5type Config struct {6 Sdk *types.SdkConfigItem `mapstructure:"sdk"`7}8var _ types.Configer = (*Config)(nil)9// GetMysqlConfig 获取数据库配置10func (c *Config) GetMysqlConfig() interface{} {11 if c == nil || c.Sdk == nil {12 return nil13 }14 return c.Sdk.Mysql15}16// GetRedisConfig 获取缓存配置17func (c *Config) GetRedisConfig() interface{} {18 if c == nil || c.Sdk == nil {19 return nil20 }21 return c.Sdk.Redis22}23// GetLogConfig 获取日志配置24func (c *Config) GetLogConfig() interface{} {25 if c == nil || c.Sdk == nil {26 return nil27 }28 return c.Sdk.Log29}30// GetRabbitmqConfig 获取消息队列配置31func (c *Config) GetRabbitmqConfig() interface{} {32 if c == nil || c.Sdk == nil {33 return nil34 }35 return c.Sdk.RabbitMq36}37// GetKafkaConfig 获取Kafka消息队列配置38func (c *Config) GetKafkaConfig() interface{} {39 if c == nil || c.Sdk == nil {40 return nil41 }42 return c.Sdk.Kafka43}44// GetMicroServiceConfig 获取Gokit微服务配置45func (c *Config) GetMicroServiceConfig() interface{} {46 if c == nil || c.Sdk == nil {47 return nil48 }49 return c.Sdk.MicroService50}51// GetNosqlConfig 获取非SQL配置52func (c *Config) GetNosqlConfig() interface{} {53 if c == nil || c.Sdk == nil {54 return nil55 }56 return c.Sdk.Nosql57}58// GetKvConfig 获取KV配置59func (c *Config) GetKvConfig() interface{} {60 if c == nil || c.Sdk == nil {61 return nil62 }63 return c.Sdk.Kv64}65// GetGraphConfig 获取图数据库配置66func (c *Config) GetGraphConfig() interface{} {67 if c == nil || c.Sdk == nil {68 return nil69 }70 return c.Sdk.Neo4j71}...

Full Screen

Full Screen

getLogConfig

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 logs.GetLogConfig()4 fmt.Println(logs.GetLogConfig())5}6import (7func main() {8 fmt.Println(logs.GetLogConfig())9}102021/02/09 11:19:16.878 [I] [1.go:12] {"filename":"/Users/rahul.raj/go/src/github.com/rahul-raj/beego/logs/logs.go","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":7,"rotate":true,"perm":"0644","color":true}

Full Screen

Full Screen

getLogConfig

Using AI Code Generation

copy

Full Screen

1import (2type LogConfig struct {3}4func main() {5 client, err := rpc.Dial("tcp", "localhost:1234")6 if err != nil {7 log.Fatal("dialing:", err)8 }9 logConfig := new(LogConfig)10 err = client.Call("Service.getLogConfig", "", logConfig)11 if err != nil {12 log.Fatal("arith error:", err)13 }14 fmt.Printf("LogConfig: %s15}16import (17type Service struct{}18type LogConfig struct {19}20func (s *Service) getLogConfig(request string, logConfig *LogConfig) error {21}22func main() {23 service := new(Service)24 rpc.Register(service)25 tcpAddr, err := net.ResolveTCPAddr("tcp", ":1234")26 if err != nil {27 log.Fatal("ResolveTCPAddr: ", err)28 }29 listener, err := net.ListenTCP("tcp", tcpAddr)30 if err != nil {31 log.Fatal("ListenTCP: ", err)32 }33 for {34 conn, err := listener.Accept()35 if err != nil {36 }37 go rpc.ServeConn(conn)38 }39}

Full Screen

Full Screen

getLogConfig

Using AI Code Generation

copy

Full Screen

1import (2var logConfig = `{3}`4func main() {5 http.HandleFunc("/log", func(w http.ResponseWriter, r *http.Request) {6 logs.SetLogger(logs.AdapterFile, logConfig)7 ctx := &context.Context{ResponseWriter: w, Request: r}8 logs.GetLogConfig(ctx)9 })10 fmt.Println("Starting server on port 8080")11 log.Fatal(http.ListenAndServe(":8080", nil))12}

Full Screen

Full Screen

getLogConfig

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 var logConfig = new(LogConfig)4 logConfig = service.getLogConfig()5 fmt.Println("LogConfig: ", logConfig)6}7import "fmt"8func main() {9 var logConfig = new(LogConfig)10 logConfig = service.getLogConfig()11 fmt.Println("LogConfig: ", logConfig)12}13import "fmt"14func main() {15 var logConfig = new(LogConfig)16 logConfig = service.getLogConfig()17 fmt.Println("LogConfig: ", logConfig)18}19import "fmt"20func main() {21 var logConfig = new(LogConfig)22 logConfig = service.getLogConfig()23 fmt.Println("LogConfig: ", logConfig)24}25import "fmt"26func main() {27 var logConfig = new(LogConfig)28 logConfig = service.getLogConfig()29 fmt.Println("LogConfig: ", logConfig)30}31import "fmt"32func main() {33 var logConfig = new(LogConfig)34 logConfig = service.getLogConfig()35 fmt.Println("LogConfig: ", logConfig)36}37import "fmt"38func main() {39 var logConfig = new(LogConfig)40 logConfig = service.getLogConfig()41 fmt.Println("LogConfig: ", logConfig)42}43import "fmt"44func main() {45 var logConfig = new(LogConfig)46 logConfig = service.getLogConfig()47 fmt.Println("LogConfig: ", logConfig)48}49import "fmt"50func main() {51 var logConfig = new(LogConfig)

Full Screen

Full Screen

getLogConfig

Using AI Code Generation

copy

Full Screen

1import "github.com/kataras/iris/v12"2func main() {3 app := iris.New()4 app.Get("/getLogConfig", func(ctx iris.Context) {5 ctx.JSON(iris.Map{"LogConfig": service.GetLogConfig()})6 })7 app.Run(iris.Addr(":8080"))8}9import "github.com/kataras/iris/v12"10func main() {11 app := iris.New()12 app.Get("/getLogConfig", func(ctx iris.Context) {13 ctx.JSON(iris.Map{"LogConfig": service.GetLogConfig()})14 })15 app.Run(iris.Addr(":8081"))16}17import (18var (19 Session = sessions.New(sessions.Config{20 })21func GetLogConfig() iris.LogConfiguration {22 return iris.LogConfiguration{23 }24}25import (26func main() {27 app := iris.New()28 redisService := redis.New(service.New())29 Session.UseDatabase(redisService)30 app.Get("/getLogConfig", func(ctx iris.Context) {31 ctx.JSON(iris.Map{"LogConfig": service.GetLogConfig()})32 })33 app.Run(iris.Addr(":8080"))34}35import (

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful