@@ -20,6 +20,7 @@ import (
2020 _ "net/http/pprof" //nolint:gosec // pprof is served on 127.0.0.1 only and gated by --enable-profiling.
2121 "os"
2222 "os/signal"
23+ "path/filepath"
2324 "syscall"
2425 "time"
2526
@@ -32,12 +33,16 @@ import (
3233const profileAddress = "127.0.0.1:6060"
3334
3435type options struct {
35- upstreamURI string
36- downstreamURI string
37- configFile string
38- consumerID string
39- logFile string
40- enableProfiling bool
36+ upstreamURI string
37+ downstreamURI string
38+ configFile string
39+ consumerID string
40+ logFile string
41+ logLevel string
42+ consumerGroupID string
43+ schemaRegistryURI string
44+ upstreamTiDBDSN string
45+ enableProfiling bool
4146}
4247
4348func main () {
@@ -96,8 +101,48 @@ func newCommand() *cobra.Command {
96101 flags .StringVar (& options .configFile , "config" , "" , "consumer configuration file" )
97102 flags .StringVar (& options .consumerID , "consumer-id" , "" ,
98103 "Kafka group ID or Pulsar subscription name (random if omitted)" )
99- flags .StringVar (& options .logFile , "log-file" , "cdc_consumer.log" , "log file path" )
104+ flags .StringVar (& options .logFile , "log-file" , defaultLogFileName () , "log file path" )
100105 flags .BoolVar (& options .enableProfiling , "enable-profiling" , false , "enable pprof on " + profileAddress )
101106
107+ // Legacy CLI flags kept hidden so copied legacy consumer names work on older branches.
108+ var ignored string
109+ flags .StringVar (& options .logLevel , "log-level" , "info" , "log level" )
110+ flags .StringVar (& options .consumerGroupID , "consumer-group-id" , "" , "legacy alias for --consumer-id" )
111+ flags .StringVar (& options .schemaRegistryURI , "schema-registry-uri" , "" , "legacy schema registry URI" )
112+ flags .StringVar (& options .upstreamTiDBDSN , "upstream-tidb-dsn" , "" , "legacy upstream TiDB DSN" )
113+ legacyStringFlags := []string {
114+ "log-level" ,
115+ "consumer-group-id" ,
116+ "schema-registry-uri" ,
117+ "upstream-tidb-dsn" ,
118+ "tz" ,
119+ "ca" ,
120+ "cert" ,
121+ "key" ,
122+ "flush-interval" ,
123+ "file-index-width" ,
124+ "oauth2-private-key" ,
125+ "oauth2-issuer-url" ,
126+ "oauth2-client-id" ,
127+ "oauth2-scope" ,
128+ "oauth2-audience" ,
129+ "auth-tls-certificate-path" ,
130+ "auth-tls-private-key-path" ,
131+ }
132+ for _ , name := range legacyStringFlags [4 :] {
133+ flags .StringVar (& ignored , name , "" , "legacy compatibility flag (ignored)" )
134+ }
135+ for _ , name := range legacyStringFlags {
136+ _ = flags .MarkHidden (name )
137+ }
138+
102139 return command
103140}
141+
142+ func defaultLogFileName () string {
143+ base := filepath .Base (os .Args [0 ])
144+ if base == "" || base == "." || base == string (filepath .Separator ) {
145+ return "cdc_consumer.log"
146+ }
147+ return base + ".log"
148+ }
0 commit comments