Skip to content

Golang linter for reporting when a message in a logger start with an uppercase

Notifications You must be signed in to change notification settings

alexisvisco/logwercase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logwercase

Logwercase is a Golang linter that report:

  • use of uppercase for message in log printer functions
  • use of non lower kebab case for WithField key in logrus

Example:

logrus.Print("Hello world") // ✗ bad
logrus.Print("hello world") // ✓ good 

logrus.WithField("Hello world", ...) // ✗ bad
logrus.WithField("hello-world", ...) // ✓ good 

It supports logrus and stdlib logger.

Installation (cli require go)

GO111MODULE=on go get github.com/alexisvisco/logwercase/cmd/logwercase@0.3.2

With golangci

cd  /tmp \
    && rm -rf logwercase \
    && git clone https://github.com/alexisvisco/logwercase \
    && cd logwercase \
    && go build -o logwercase.so -buildmode=plugin plugin/plugin.go \
    && cp logwercase.so /home/$USER/go/bin/ \
    && echo "logwercase.so created and set in " /home/$USER/go/bin/logwercase.so

In your .golangci.yml add these lines:

linters-settings:
  custom:
    logwercase:
      path: /home/$USER/go/bin/logwercase.so
      description: Analyze case of log message and WithField keys
      original-url: github.com/alexisvisco/logwercase

Change $USER with your user

About

Golang linter for reporting when a message in a logger start with an uppercase

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages