Skip to content

Commit

Permalink
SNOW-856228 Disable easy logging (#962)
Browse files Browse the repository at this point in the history
SNOW-856228 Disable easy logging
  • Loading branch information
sfc-gh-knozderko authored Nov 9, 2023
1 parent 1b2dae6 commit 730c03c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 44 deletions.
9 changes: 5 additions & 4 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,11 @@ func buildSnowflakeConn(ctx context.Context, config Config) (*snowflakeConn, err
queryContextCache: (&queryContextCache{}).init(),
currentTimeProvider: defaultTimeProvider,
}
err := initEasyLogging(config.ClientConfigFile)
if err != nil {
return nil, err
}
// Easy logging is temporarily disabled
//err := initEasyLogging(config.ClientConfigFile)
//if err != nil {
// return nil, err
//}
var st http.RoundTripper = SnowflakeTransport
if sc.cfg.Transporter == nil {
if sc.cfg.InsecureMode {
Expand Down
40 changes: 0 additions & 40 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,46 +167,6 @@ Users can use SetLogger in driver.go to set a customized logger for gosnowflake
In order to enable debug logging for the driver, user could use SetLogLevel("debug") in SFLogger interface
as shown in demo code at cmd/logger.go. To redirect the logs SFlogger.SetOutput method could do the work.
## Easy Logging
The Easy Logging feature allows you to change log level and the location of a log file for the driver.
This feature was introduced to make tracing of driver's logs easier.
The feature is activated by a config file which can be:
1. provided as clientConfigFile parameter.
Remember to URL-encode all special characters on file path if you use DSN string e. g.
`user:pass@account/db?clientConfigFile=%2Fsome-path%2Fclient_config.json` encodes clientConfigFile `/some-path/client_config.json`
2. provided as environmental variable called `SF_CLIENT_CONFIG_FILE` (e. g. `export SF_CLIENT_CONFIG_FILE=/some-path/client_config.json`)
3. found in the driver location by searching for sf_client_config.json file
4. found in the home location by searching for sf_client_config.json file
5. found in temp directory location by searching for sf_client_config.json file
The search for a config file is executed in the order listed above.
To minimize the number of searches for a configuration file it is executed only:
- for the first connection
- for the first connection with clientConfigFile parameter.
The example of the configuration file is:
```
{
"common": {
"log_level": "INFO",
"log_path": "/some-path/some-directory"
}
}
```
Available log levels are: OFF, ERROR, WARN, INFO, DEBUG, TRACE. The log levels are case insensitive.
The logs land into `go` subfolder of given directory `/some-path/some-directory` so in this example: /some-path/some-directory/go.
# Query request ID
A specific query request ID can be set in the context and will be passed through
Expand Down
1 change: 1 addition & 0 deletions easy_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (i *initTrials) reset() {
i.configureCounter = 0
}

//lint:ignore U1000 Ignore unused function
func initEasyLogging(clientConfigFileInput string) error {
if !allowedToInitialize(clientConfigFileInput) {
return nil
Expand Down
6 changes: 6 additions & 0 deletions easy_logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

func TestInitializeEasyLoggingOnlyOnceWhenConfigGivenAsAParameter(t *testing.T) {
t.Skip("Skip until easy logging enabled")
defer cleanUp()
dir := t.TempDir()
logLevel := levelError
Expand All @@ -35,6 +36,7 @@ func TestInitializeEasyLoggingOnlyOnceWhenConfigGivenAsAParameter(t *testing.T)
}

func TestConfigureEasyLoggingOnlyOnceWhenInitializedWithoutConfigFilePath(t *testing.T) {
t.Skip("Skip until easy logging enabled")
defer cleanUp()
dir := t.TempDir()
logLevel := levelError
Expand All @@ -53,6 +55,7 @@ func TestConfigureEasyLoggingOnlyOnceWhenInitializedWithoutConfigFilePath(t *tes
}

func TestReconfigureEasyLoggingIfConfigPathWasNotGivenForTheFirstTime(t *testing.T) {
t.Skip("Skip until easy logging enabled")
defer cleanUp()
dir := t.TempDir()
tmpDirLogLevel := levelError
Expand Down Expand Up @@ -85,6 +88,7 @@ func TestReconfigureEasyLoggingIfConfigPathWasNotGivenForTheFirstTime(t *testing
}

func TestEasyLoggingFailOnUnknownLevel(t *testing.T) {
t.Skip("Skip until easy logging enabled")
defer cleanUp()
dir := t.TempDir()
easyLoggingInitTrials.reset()
Expand All @@ -99,6 +103,7 @@ func TestEasyLoggingFailOnUnknownLevel(t *testing.T) {
}

func TestEasyLoggingFailOnNotExistingConfigFile(t *testing.T) {
t.Skip("Skip until easy logging enabled")
defer cleanUp()
easyLoggingInitTrials.reset()

Expand All @@ -110,6 +115,7 @@ func TestEasyLoggingFailOnNotExistingConfigFile(t *testing.T) {
}

func TestLogToConfiguredFile(t *testing.T) {
t.Skip("Skip until easy logging enabled")
defer cleanUp()
dir := t.TempDir()
easyLoggingInitTrials.reset()
Expand Down

0 comments on commit 730c03c

Please sign in to comment.