vitess.io/vitess@v0.16.2/go/vt/topotools/events/reparent_syslog.go (about)

     1  /*
     2  Copyright 2019 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package events
    18  
    19  import (
    20  	"fmt"
    21  	"log/syslog"
    22  
    23  	"vitess.io/vitess/go/vt/proto/topodata"
    24  
    25  	"vitess.io/vitess/go/event/syslogger"
    26  	"vitess.io/vitess/go/vt/topo/topoproto"
    27  )
    28  
    29  // Syslog writes a Reparent event to syslog.
    30  func (r *Reparent) Syslog() (syslog.Priority, string) {
    31  	var oldAlias *topodata.TabletAlias
    32  	var newAlias *topodata.TabletAlias
    33  	if r.OldPrimary != nil {
    34  		oldAlias = r.OldPrimary.Alias
    35  	}
    36  	if r.NewPrimary != nil {
    37  		newAlias = r.NewPrimary.Alias
    38  	}
    39  
    40  	return syslog.LOG_INFO, fmt.Sprintf("%s/%s [reparent %v -> %v] %s (%s)",
    41  		r.ShardInfo.Keyspace(), r.ShardInfo.ShardName(),
    42  		topoproto.TabletAliasString(oldAlias),
    43  		topoproto.TabletAliasString(newAlias),
    44  		r.Status, r.ExternalID)
    45  }
    46  
    47  var _ syslogger.Syslogger = (*Reparent)(nil) // compile-time interface check