Skip to content

feat: global klog standardization#1429

Open
0x0034 wants to merge 74 commits into
flashcatcloud:mainfrom
0x0034:feat/global-klog-standardization
Open

feat: global klog standardization#1429
0x0034 wants to merge 74 commits into
flashcatcloud:mainfrom
0x0034:feat/global-klog-standardization

Conversation

@0x0034
Copy link
Copy Markdown
Contributor

@0x0034 0x0034 commented Apr 14, 2026

No description provided.

0x0034 added 30 commits April 14, 2026 00:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes runtime logging across the codebase by replacing Go’s standard log usage (and DebugMode-gated logging) with k8s.io/klog/v2, and centralizes log configuration (output + verbosity) behind a new pkg/logging package and new config fields.

Changes:

  • Replace log.Printf/Println calls throughout writers, inputs, logs pipeline, agent, API, and utilities with klog APIs (InfoS, ErrorS, Warningf, V(n)).
  • Introduce pkg/logging to initialize klog flags/output, bridge the stdlib logger into klog, and provide Sync() for flushing.
  • Add config-level log.level / log.verbosity (and tests) to drive effective verbosity/debug behavior.

Reviewed changes

Copilot reviewed 286 out of 286 changed files in this pull request and generated no comments.

Show a summary per file
File Description
writer/writers.go Switch writer debug/error logs to klog + V-level gating.
writer/writer.go Switch remote-write error logging to structured klog.
pkg/pprof/profile.go Replace stdlib logging with klog for pprof lifecycle logs.
pkg/logging/logging.go New centralized klog configuration (output/verbosity/bridging/flush).
pkg/kubernetes/pod.go Replace stdlib warnings with klog warnings.
pkg/httpx/transport.go Replace warn-once logging with klog warnings.
pkg/httpx/client.go Replace reset warning with klog warning.
pkg/aop/logger.go Switch Gin request logging emission to klog.
parser/prometheus/parser.go Switch parse error logs to klog.
parser/influx/parser.go Switch parse error logs to klog (includes input as field).
main_posix.go Remove stdlib log usage; use klog in reap daemon on Linux.
logs/util/kubernetes/tags/builder.go Replace tag build warnings with klog warnings.
logs/util/kubernetes/kubelet/podwatcher.go Switch pod-change debug logging to klog V-level.
logs/util/docker/storage.go Replace docker storage warnings/info with klog.
logs/util/docker/rancher.go Replace Rancher label parse warning with klog warning.
logs/util/docker/global.go Replace Docker init warning with klog warning.
logs/util/docker/event_stream.go Replace event stream logs with klog (V-level + warnings).
logs/util/docker/event_pull.go Replace event parsing logs with klog.
logs/util/docker/docker.go Replace docker util logs with klog.
logs/util/containers/providers/provider.go Replace duplicate-provider warning with klog warning.
logs/util/containers/filter.go Replace filter warnings/debug logs with klog.
logs/tag/provider.go Remove commented stdlib log usage reference.
logs/sender/stream_strategy.go Replace send failure logging with klog warning.
logs/sender/batch_strategy.go Replace batch buffer/drop/send logging with klog.
logs/processor/processor.go Replace encode/debug logs with klog.
logs/message/origin.go Replace marshal error logging with klog.
logs/input/listener/udp.go Replace UDP listener lifecycle/error logs with klog.
logs/input/listener/tailer.go Replace tailer read warnings with klog.
logs/input/kubernetes/scanner.go Replace kubelet connection/list warnings with klog.
logs/input/journald/tailer.go Replace journald tailer lifecycle/errors with klog.
logs/input/journald/launcher.go Replace tailer setup error logging with klog.
logs/input/file/tailer_windows.go Replace file tailer logs with klog on Windows.
logs/input/file/tailer_nix.go Replace file tailer debug logs with klog V-level.
logs/input/file/tailer.go Replace rotation/close logs with klog.
logs/input/file/file_provider.go Replace file provider info/warn logs with klog.
logs/input/container/launcher.go Replace retry/lifecycle logs with klog.
logs/decoder/line_parser.go Replace parse error logging with klog (structured for multiline).
logs/decoder/decoder.go Replace autodetect/multiline config logs with klog.
logs/decoder/auto_multiline_handler.go Replace autosense logs with klog.
logs/client/kafka/producer.go Replace Kafka producer logs with klog (+ V-level debug).
logs/client/kafka/destination.go Replace Kafka destination logs with klog.
logs/client/http/destination.go Replace HTTP destination logs with klog; adjust comments.
logs/auditor/auditor.go Replace auditor warnings/errors with klog.
inputs/vsphere/vsphere.go Replace vsphere init/gather logs with klog.
inputs/vsphere/tscache.go Replace cache purge debug logging with klog V-level.
inputs/vsphere/finder.go Replace finder info logs with structured klog.
inputs/traffic_server/traffic_server.go Replace debug/error logs with klog.
inputs/tomcat/tomcat.go Replace tomcat query/decode/status logs with klog.
inputs/tengine/tengine.go Replace parse/gather/debug logs with klog.
inputs/system/system.go Replace system gather warnings/errors with klog.
inputs/system/ps.go Replace disk usage error logging with klog.
inputs/sqlserver/sqlserver.go Replace sqlserver init/config/gather logs with klog.
inputs/sockstat/sockstat.go Replace sockstat logs with klog (debug via V-level).
inputs/snmp_zabbix/template.go Replace formula parse/eval/type logs with structured klog.
inputs/snmp_zabbix/preprocessing.go Replace preprocessing logs with klog; JS console routed to klog.
inputs/snmp_zabbix/collector.go Replace SNMP collector debug logs with structured klog.
inputs/snmp/netsnmp.go Replace command debug logging with structured klog.
inputs/snmp/instances.go Replace SNMP instance logs with structured klog.
inputs/snmp/health_check.go Replace health-check logs with structured klog.
inputs/self_metrics/metrics.go Replace self-metrics gather error logging with klog.
inputs/redis_sentinel/redis_sentinel.go Replace sentinel gather errors with structured klog.
inputs/redfish/redfish.go Replace redfish gather/get errors with structured klog.
inputs/provider_manager.go Replace provider selection/dup logs with structured klog.
inputs/procstat/win_service_windows.go Replace service-close error with structured klog.
inputs/processes/processes_notwindows.go Replace processes gather warnings/errors with klog.
inputs/ping/ping_windows.go Replace ping debug/errors with structured klog.
inputs/ping/ping_notwindows.go Replace ping debug/errors with structured klog.
inputs/phpfpm/phpfpm.go Replace php-fpm logs with structured klog.
inputs/nvidia_smi/nvidia_smi.go Replace GPU transform debug logs with structured klog.
inputs/nvidia_smi/builder.go Replace nvidia-smi warnings with klog.
inputs/ntp/ntp_test.go Avoid direct stdlib log.* usage by using an aliased logger.
inputs/ntp/ntp.go Replace NTP connect errors with structured klog.
inputs/node_exporter/exporter.go Replace node exporter collect error with structured klog.
inputs/node_exporter/collector/textfile.go Replace textfile collector warnings/errors with klog.
inputs/node_exporter/collector/systemd_linux.go Replace deprecation warnings with klog.
inputs/node_exporter/collector/supervisord.go Replace deprecation warning with klog.
inputs/node_exporter/collector/runit.go Replace deprecation warning with klog.
inputs/node_exporter/collector/qdisc_linux.go Replace deprecation warnings with klog.
inputs/node_exporter/collector/perf_linux.go Replace perf collection errors with structured klog.
inputs/node_exporter/collector/ntp.go Replace deprecation warning with klog.
inputs/node_exporter/collector/netdev_common.go Replace flag parsing/deprecation logs with structured klog.
inputs/node_exporter/collector/netclass_rtnl_linux.go Replace info log with klog.
inputs/node_exporter/collector/filesystem_common.go Replace flag parsing/deprecation logs with structured klog.
inputs/node_exporter/collector/diskstats_linux.go Replace udev/ATA parse errors with structured klog.
inputs/node_exporter/collector/diskstats_common.go Replace deprecation/flag logs with structured klog.
inputs/node_exporter/collector/cpu_linux.go Replace info log with klog.
inputs/node_exporter/collector/collector.go Replace invalid filter/collector execution logs with structured klog.
inputs/node_exporter/collector/buddyinfo.go Replace debug log with structured klog.
inputs/nginx_upstream_check/nginx_upstream_check.go Replace debug/error logs with structured klog.
inputs/nginx/nginx.go Replace nginx gather/debug/close errors with structured klog.
inputs/netstat_filter/netstat_filter.go Replace netstat filter errors with structured klog.
inputs/netstat/netstat.go Replace netstat errors/warnings with structured klog.
inputs/net/net.go Replace net IO/interface errors with structured klog.
inputs/nats/nats.go Replace NATS gather errors/debug with structured klog.
inputs/mysql/table_size.go Replace mysql query/scan errors with structured klog.
inputs/mysql/slave_status.go Replace mysql replica/slave status errors with structured klog.
inputs/mysql/schema_size.go Replace mysql query/scan errors with structured klog.
inputs/mysql/processlist_by_user.go Replace mysql query/scan errors with structured klog.
inputs/mysql/processlist.go Replace mysql query/scan warnings/errors with structured klog.
inputs/mysql/mysql.go Replace mysql open/ping errors with structured klog.
inputs/mysql/global_variables.go Replace mysql query errors with structured klog.
inputs/mysql/global_status.go Replace mysql query errors with structured klog.
inputs/mysql/engine_innodb.go Replace mysql query/scan errors with structured klog.
inputs/mysql/binlog.go Replace mysql binlog query/shape errors with structured klog.
inputs/mtail/mtail.go Replace mtail init/gather errors with structured klog.
inputs/mtail/internal/tailer/tail.go Replace tailer polling/glob errors with structured klog.
inputs/mtail/internal/tailer/logstream/socketstream.go Replace socket stream errors with structured klog.
inputs/mtail/internal/tailer/logstream/logstream.go Replace parse-url debug logging with klog V-level.
inputs/mtail/internal/tailer/logstream/fifostream.go Replace FIFO open/close errors with structured klog.
inputs/mtail/internal/tailer/logstream/dgramstream.go Replace dgram close errors with structured klog.
inputs/mtail/internal/tailer/logstream/cancel.go Replace cancel/debug logs with klog V-level + structured errors.
inputs/mtail/internal/runtime/vm/vm.go Replace VM runtime/error trace logs with structured klog.
inputs/mtail/internal/runtime/compiler/types/types.go Replace unexpected-type warning with klog.
inputs/mtail/internal/runtime/compiler/parser/lexer.go Replace unread-rune error with structured klog.
inputs/mtail/internal/runtime/compiler/compiler.go Replace AST debug logging with klog V-level.
inputs/mtail/internal/runtime/compiler/codegen/codegen.go Replace incomplete-type warnings with klog.
inputs/mtail/internal/runtime/compiler/checker/checker.go Replace checker warnings with klog.
inputs/mtail/internal/mtail/mtail.go Replace compile-only log with structured klog.
inputs/mtail/internal/mtail/httpstatus.go Replace status write errors with structured klog.
inputs/mtail/internal/metrics/store.go Replace store GC loop logs with structured klog.
inputs/mtail/internal/metrics/metric.go Replace remove-oldest warning with klog.
inputs/mtail/internal/exporter/prometheus.go Replace metric construction errors with structured klog.
inputs/mtail/internal/exporter/json.go Replace JSON export errors with structured klog.
inputs/mtail/internal/exporter/export.go Replace push/export loop logs with structured klog.
inputs/mongodb/mongodb.go Replace mongodb collect error with structured klog.
inputs/mem/mem.go Replace vmstat error logging with structured klog.
inputs/linux_sysctl_fs/linux_sysctl_fs_linux.go Replace sysctl gather errors with structured klog.
inputs/ldap/ldap.go Replace ldap connect/search/gather errors with structured klog.
inputs/kubernetes/kubernetes.go Replace kubelet summary/podinfo errors with structured klog.
inputs/kernel_vmstat/kernel_vmstat.go Replace vmstat read/parse debug logs with structured klog.
inputs/kernel/kernel.go Replace kernel stat read/parse errors with structured klog.
inputs/kafka/kafka.go Resolve klog name conflict; keep go-kit logger for exporter and use klog for errors.
inputs/jolokia_proxy/jolokia_proxy.go Replace client creation/gather logs with structured klog.
inputs/jolokia_agent/jolokia_agent.go Replace client creation/gather logs with structured klog.
inputs/jolokia/gatherer.go Replace point generation errors with structured klog.
inputs/ipvs/ipvs_linux_amd64.go Replace IPVS handle/service errors with structured klog.
inputs/iptables/iptables.go Replace config/gather errors with structured klog.
inputs/ipmi/instances.go Replace descriptor/label/metric errors with structured klog.
inputs/ipmi/exporter/freeipmi/freeipmi.go Replace pipe/execute/cleanup logs with structured klog.
inputs/ipmi/exporter/collector_sm_lan_mode.go Replace LAN mode collector errors with structured klog.
inputs/ipmi/exporter/collector_sel.go Replace SEL collector errors with structured klog.
inputs/ipmi/exporter/collector_notwindows.go Replace debug timing/collector logs with klog V-level.
inputs/ipmi/exporter/collector_ipmi.go Replace sensor collection logs with structured klog.
inputs/ipmi/exporter/collector_dcmi.go Replace DCMI collector errors with structured klog.
inputs/ipmi/exporter/collector_chassis.go Replace chassis collector errors with structured klog.
inputs/ipmi/exporter/collector_bmc.go Replace BMC collector errors with structured klog.
inputs/inputs.go Add logger-aware initializer path (InitWithLogger) via updated MayInit.
inputs/haproxy/haproxy.go Replace exporter collect error with structured klog.
inputs/hadoop/hadoop.go Replace component fetch errors with structured klog.
inputs/greenplum/greenplum.go Replace parse error logs with structured klog.
inputs/googlecloud/instances.go Replace client close / nil client / list/read errors with structured klog.
inputs/gnmi/gnmi.go Replace init/start debug/warn logs with structured klog.
inputs/filecount/filecount.go Replace walk/filter errors with structured klog.
inputs/exec/exec.go Replace exec glob/parse/run/parse errors with structured klog.
inputs/ethtool/namespace_linux.go Replace namespace errors with structured klog.
inputs/ethtool/ethtool_notlinux.go Replace unsupported-platform error with klog.
inputs/elasticsearch/pkg/roundtripper/roundtripper.go Replace AWS signing transport errors with structured klog.
inputs/elasticsearch/collector/util.go Replace response close errors with structured klog.
inputs/elasticsearch/collector/tasks.go Replace response close errors with structured klog.
inputs/elasticsearch/collector/shards.go Replace cluster-info loop and fetch errors with klog.
inputs/elasticsearch/collector/nodes.go Replace response close/fetch errors with structured klog.
inputs/elasticsearch/collector/indices_settings.go Replace response close/fetch errors with structured klog.
inputs/elasticsearch/collector/indices_mappings.go Replace read/close/fetch errors with structured klog.
inputs/elasticsearch/collector/indices.go Replace alias/fetch errors with structured klog.
inputs/elasticsearch/collector/collector.go Replace collector success/failure logs with structured klog.
inputs/elasticsearch/collector/cluster_stats.go Replace response close/fetch errors with structured klog.
inputs/elasticsearch/collector/cluster_health_indices.go Replace response close/fetch errors with structured klog.
inputs/elasticsearch/collector/cluster_health.go Replace response close/fetch errors with structured klog.
inputs/elasticsearch/collector/categraf_utils.go Replace response close errors with structured klog.
inputs/dns_query/dns_query.go Replace DNS detection/query errors with structured klog.
inputs/dmesg/dmesg.go Replace kmsg open/read errors with structured klog.
inputs/diskio/diskio.go Replace diskio gather errors with structured klog.
inputs/disk/disk.go Replace disk usage errors with structured klog.
inputs/cpu/cpu.go Replace CPU gather warnings/errors with structured klog.
inputs/consul/consul.go Replace consul gather error with structured klog.
inputs/conntrack/conntrack.go Replace conntrack read/parse/no-metrics errors with structured klog.
inputs/collector.go Replace metrics collect logging with structured klog.
inputs/chrony/chrony.go Replace chrony run/parse/no-metrics errors with klog.
inputs/bind/bind.go Replace bind parse/gather logs with klog.
inputs/aliyun/internal/manager/cms.go Replace CMS request debug/error logs with structured klog.
ibex/tasks.go Replace unknown action warning with klog warning.
ibex/heartbeat.go Replace heartbeat lifecycle/rpc/message logs with structured klog.
heartbeat/platform/platform_darwin.go Replace Rosetta detection logs with klog.
heartbeat/memory/memory.go Replace parse warnings with klog warnings.
config/urllabel.go Replace debug logging of URL label templates/pairs with klog V-level.
config/hostname.go Replace update-loop errors with structured klog.
config/config_test.go Add unit tests for log.level/log.verbosity resolution behavior.
conf/config.toml Document and add log.level + log.verbosity settings.
api/server.go Replace server startup log with structured klog.
api/router_opentsdb.go Replace opentsdb clean/convert/error logs with structured klog.
api/router_falcon.go Replace falcon forwarder error logs with structured klog.
agent/update/update_linux.go Replace updater logs with structured klog.
agent/prometheus_agent.go Replace module lifecycle logs with klog.
agent/metrics_reader.go Replace debug logs and panic reporting with structured klog.
agent/install/service_linux.go Replace timeout/path error logs with structured klog.
agent/ibex_agent.go Replace disabled-module log with klog.
agent/agent.go Replace agent/module lifecycle logs with structured klog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot added the stale label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants