Skip to content

Commit

Permalink
Add WARN log level
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunlol committed Nov 28, 2024
1 parent c58814c commit 8c4a9f2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sh:
devbox shell
devbox --env-file .env shell

install:
devbox run "cd src && go mod tidy"
Expand Down
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="0.14.3"
VERSION="0.14.4"

# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
Expand Down
8 changes: 8 additions & 0 deletions src/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ type LogLevel string

const (
LOG_LEVEL_DEBUG = "DEBUG"
LOG_LEVEL_WARN = "WARN"
LOG_LEVEL_INFO = "INFO"
LOG_LEVEL_ERROR = "ERROR"
)

var LOG_LEVELS = []string{
LOG_LEVEL_DEBUG,
LOG_LEVEL_WARN,
LOG_LEVEL_INFO,
LOG_LEVEL_ERROR,
}
Expand All @@ -22,6 +24,12 @@ func LogError(config *Config, message ...interface{}) {
log.Println(append([]interface{}{"[ERROR]"}, message...)...)
}

func LogWarn(config *Config, message ...interface{}) {
if config.LogLevel == LOG_LEVEL_WARN || config.LogLevel == LOG_LEVEL_INFO || config.LogLevel == LOG_LEVEL_DEBUG {
log.Println(append([]interface{}{"[WARN]"}, message...)...)
}
}

func LogInfo(config *Config, message ...interface{}) {
if config.LogLevel == LOG_LEVEL_INFO || config.LogLevel == LOG_LEVEL_DEBUG {
log.Println(append([]interface{}{"[INFO]"}, message...)...)
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

const VERSION = "0.14.3"
const VERSION = "0.14.4"

func main() {
config := LoadConfig()
Expand Down
2 changes: 1 addition & 1 deletion src/select_remapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (selectRemapper *SelectRemapper) RemapQueryTreeWithSet(queryTree *pgQuery.P
setStatement := queryTree.Stmts[0].Stmt.GetVariableSetStmt()

if !KNOWN_SET_STATEMENTS.Contains(setStatement.Name) {
LogError(selectRemapper.config, "Unsupported SET ", setStatement.Name, ":", setStatement)
LogWarn(selectRemapper.config, "Unsupported SET ", setStatement.Name, ":", setStatement)
}

queryTree.Stmts[0].Stmt.GetVariableSetStmt().Name = "schema"
Expand Down

0 comments on commit 8c4a9f2

Please sign in to comment.