lazy evaluation of log fields

This commit is contained in:
v2ray
2016-01-18 12:24:33 +01:00
parent 8f20933457
commit eec0bb4db4
25 changed files with 124 additions and 117 deletions
+2 -2
View File
@@ -138,14 +138,14 @@ func JsonLoadConfig(file string) (*Config, error) {
fixedFile := os.ExpandEnv(file)
rawConfig, err := ioutil.ReadFile(fixedFile)
if err != nil {
log.Error("Failed to read server config file (%s): %v", file, err)
log.Error("Failed to read server config file (", file, "): ", file, err)
return nil, err
}
jsonConfig := &Config{}
err = json.Unmarshal(rawConfig, jsonConfig)
if err != nil {
log.Error("Failed to load server config: %v", err)
log.Error("Failed to load server config: ", err)
return nil, err
}
+2 -2
View File
@@ -28,7 +28,7 @@ func (this *InboundDetourHandler) Initialize() error {
ichConfig := this.config.Settings
ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol, this.space, ichConfig)
if err != nil {
log.Error("Failed to create inbound connection handler: %v", err)
log.Error("Failed to create inbound connection handler: ", err)
return err
}
this.ich = append(this.ich, &InboundConnectionHandlerWithPort{
@@ -51,7 +51,7 @@ func (this *InboundDetourHandler) Start() error {
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
err := ich.handler.Listen(ich.port)
if err != nil {
log.Error("Failed to start inbound detour on port %d: %v", ich.port, err)
log.Error("Failed to start inbound detour on port ", ich.port, ": ", err)
return err
}
return nil
+7 -7
View File
@@ -58,7 +58,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
ichConfig := pConfig.InboundConfig.Settings
ich, err := proxyrepo.CreateInboundConnectionHandler(pConfig.InboundConfig.Protocol, vpoint.space.ForContext("vpoint-default-inbound"), ichConfig)
if err != nil {
log.Error("Failed to create inbound connection handler: %v", err)
log.Error("Failed to create inbound connection handler: ", err)
return nil, err
}
vpoint.ich = ich
@@ -66,7 +66,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
ochConfig := pConfig.OutboundConfig.Settings
och, err := proxyrepo.CreateOutboundConnectionHandler(pConfig.OutboundConfig.Protocol, vpoint.space.ForContext("vpoint-default-outbound"), ochConfig)
if err != nil {
log.Error("Failed to create outbound connection handler: %v", err)
log.Error("Failed to create outbound connection handler: ", err)
return nil, err
}
vpoint.och = och
@@ -93,7 +93,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
for _, detourConfig := range outboundDetours {
detourHandler, err := proxyrepo.CreateOutboundConnectionHandler(detourConfig.Protocol, vpoint.space.ForContext(detourConfig.Tag), detourConfig.Settings)
if err != nil {
log.Error("Failed to create detour outbound connection handler: %v", err)
log.Error("Failed to create detour outbound connection handler: ", err)
return nil, err
}
vpoint.odh[detourConfig.Tag] = detourHandler
@@ -104,7 +104,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
if routerConfig != nil {
r, err := router.CreateRouter(routerConfig.Strategy, routerConfig.Settings)
if err != nil {
log.Error("Failed to create router: %v", err)
log.Error("Failed to create router: ", err)
return nil, BadConfiguration
}
vpoint.router = r
@@ -124,7 +124,7 @@ func (this *Point) Close() {
// In the case of any errors, the state of the server is unpredicatable.
func (this *Point) Start() error {
if this.port <= 0 {
log.Error("Invalid port %d", this.port)
log.Error("Invalid port ", this.port)
return BadConfiguration
}
@@ -133,7 +133,7 @@ func (this *Point) Start() error {
if err != nil {
return err
}
log.Warning("Point server started on port %d", this.port)
log.Warning("Point server started on port ", this.port)
return nil
})
if err != nil {
@@ -162,7 +162,7 @@ func (this *Point) DispatchToOutbound(context app.Context, packet v2net.Packet)
if this.router != nil {
if tag, err := this.router.TakeDetour(dest); err == nil {
if handler, found := this.odh[tag]; found {
log.Info("Point: Taking detour [%s] for [%s]", tag, dest)
log.Info("Point: Taking detour [", tag, "] for [", dest, "]", tag, dest)
dispatcher = handler
}
}