mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-18 16:30:44 +00:00
Implement custom logger with log levels
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package memoryexecutor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/pikami/cosmium/internal/logger"
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
)
|
||||
|
||||
@@ -36,13 +36,13 @@ func (c memoryExecutorContext) array_Slice(arguments []interface{}, row RowType)
|
||||
lengthEx := c.getFieldValue(arguments[2].(parsers.SelectItem), row)
|
||||
|
||||
if length, ok = lengthEx.(int); !ok {
|
||||
fmt.Println("array_Slice - got length parameters of wrong type")
|
||||
logger.Error("array_Slice - got length parameters of wrong type")
|
||||
return []interface{}{}
|
||||
}
|
||||
}
|
||||
|
||||
if start, ok = startEx.(int); !ok {
|
||||
fmt.Println("array_Slice - got start parameters of wrong type")
|
||||
logger.Error("array_Slice - got start parameters of wrong type")
|
||||
return []interface{}{}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func (c memoryExecutorContext) parseArray(argument interface{}, row RowType) []i
|
||||
|
||||
arrValue := reflect.ValueOf(ex)
|
||||
if arrValue.Kind() != reflect.Slice {
|
||||
fmt.Println("parseArray got parameters of wrong type")
|
||||
logger.Error("parseArray got parameters of wrong type")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/pikami/cosmium/internal/logger"
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
)
|
||||
|
||||
@@ -168,7 +169,7 @@ func (c memoryExecutorContext) getFieldValue(field parsers.SelectItem, row RowTy
|
||||
var ok bool
|
||||
if typedValue, ok = field.Value.(parsers.Constant); !ok {
|
||||
// TODO: Handle error
|
||||
fmt.Println("parsers.Constant has incorrect Value type")
|
||||
logger.Error("parsers.Constant has incorrect Value type")
|
||||
}
|
||||
|
||||
if typedValue.Type == parsers.ConstantTypeParameterConstant &&
|
||||
@@ -186,7 +187,7 @@ func (c memoryExecutorContext) getFieldValue(field parsers.SelectItem, row RowTy
|
||||
var ok bool
|
||||
if typedValue, ok = field.Value.(parsers.FunctionCall); !ok {
|
||||
// TODO: Handle error
|
||||
fmt.Println("parsers.Constant has incorrect Value type")
|
||||
logger.Error("parsers.Constant has incorrect Value type")
|
||||
}
|
||||
|
||||
switch typedValue.Type {
|
||||
@@ -288,7 +289,7 @@ func (c memoryExecutorContext) getExpressionParameterValue(
|
||||
return c.getFieldValue(typedParameter, row)
|
||||
}
|
||||
|
||||
fmt.Println("getExpressionParameterValue - got incorrect parameter type")
|
||||
logger.Error("getExpressionParameterValue - got incorrect parameter type")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pikami/cosmium/internal/logger"
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
)
|
||||
|
||||
@@ -118,7 +119,7 @@ func (c memoryExecutorContext) strings_Left(arguments []interface{}, row RowType
|
||||
lengthEx := c.getFieldValue(arguments[1].(parsers.SelectItem), row)
|
||||
|
||||
if length, ok = lengthEx.(int); !ok {
|
||||
fmt.Println("strings_Left - got parameters of wrong type")
|
||||
logger.Error("strings_Left - got parameters of wrong type")
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ func (c memoryExecutorContext) strings_Replicate(arguments []interface{}, row Ro
|
||||
timesEx := c.getFieldValue(arguments[1].(parsers.SelectItem), row)
|
||||
|
||||
if times, ok = timesEx.(int); !ok {
|
||||
fmt.Println("strings_Replicate - got parameters of wrong type")
|
||||
logger.Error("strings_Replicate - got parameters of wrong type")
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -190,7 +191,7 @@ func (c memoryExecutorContext) strings_Right(arguments []interface{}, row RowTyp
|
||||
lengthEx := c.getFieldValue(arguments[1].(parsers.SelectItem), row)
|
||||
|
||||
if length, ok = lengthEx.(int); !ok {
|
||||
fmt.Println("strings_Right - got parameters of wrong type")
|
||||
logger.Error("strings_Right - got parameters of wrong type")
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -219,11 +220,11 @@ func (c memoryExecutorContext) strings_Substring(arguments []interface{}, row Ro
|
||||
lengthEx := c.getFieldValue(arguments[2].(parsers.SelectItem), row)
|
||||
|
||||
if startPos, ok = startPosEx.(int); !ok {
|
||||
fmt.Println("strings_Substring - got start parameters of wrong type")
|
||||
logger.Error("strings_Substring - got start parameters of wrong type")
|
||||
return ""
|
||||
}
|
||||
if length, ok = lengthEx.(int); !ok {
|
||||
fmt.Println("strings_Substring - got length parameters of wrong type")
|
||||
logger.Error("strings_Substring - got length parameters of wrong type")
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -263,7 +264,7 @@ func (c memoryExecutorContext) parseString(argument interface{}, row RowType) st
|
||||
return str1
|
||||
}
|
||||
|
||||
fmt.Println("StringEquals got parameters of wrong type")
|
||||
logger.Error("StringEquals got parameters of wrong type")
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user