You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/07/22 20:18:46 UTC

[GitHub] [trafficcontrol] jpappa200 opened a new pull request #6052: T3c logger

jpappa200 opened a new pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052


   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [X] This PR is not related to any Issue <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   This PR updates print statements to use go logger library for the maple forwarder. 
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   
   - Traffic Ops ORT
   
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   Build, install on a cache, queue updates, and run t3c apply
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   
   Not a bug fix.
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [X] This PR includes tests OR I have explained why tests are unnecessary
   - [X] This PR includes documentation OR I have explained why documentation is unnecessary
   - [X] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [X] This PR includes any and all required license headers
   - [X] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   ## Additional Information
   <!-- If you would like to include any additional information on the PR for
   potential reviewers please put it here.
   
   Some examples of this would be:
   
   - Before and after screenshots/gifs of the Traffic Portal if it is affected
   - Links to other dependent Pull Requests
   - References to relevant context (e.g. new/updates to dependent libraries,
   mailing list records, blueprints)
   
   Feel free to leave this section blank (or, preferably, delete it entirely).
   -->
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675809258



##########
File path: cache-config/t3c-generate/update-to-client/update-to-client.go
##########
@@ -32,26 +33,26 @@ import (
 
 func main() {
 	if len(os.Args) < 3 {
-		fmt.Fprintf(os.Stdout, usageStr())
+		log.Errorln(usageStr())

Review comment:
       Added log.Init()




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675809692



##########
File path: cache-config/t3c/t3c.go
##########
@@ -48,18 +48,18 @@ func main() {
 	flagHelp := getopt.BoolLong("help", 'h', "Print usage information and exit")
 	getopt.Parse()
 	if *flagHelp {
-		fmt.Println(usageStr())
+		log.Errorln(usageStr())

Review comment:
       Added log.Init()




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675810076



##########
File path: cache-config/t3c-diff/t3c-diff.go
##########
@@ -36,31 +36,31 @@ func main() {
 	help := getopt.BoolLong("help", 'h', "Print usage info and exit")
 	getopt.ParseV2()
 	if *help {
-		fmt.Println(usageStr)
+		log.Errorln(usageStr)

Review comment:
       Added log.Init()




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675817551



##########
File path: cache-config/t3c-check/t3c-check.go
##########
@@ -43,18 +43,18 @@ func main() {
 	flagHelp := getopt.BoolLong("help", 'h', "Print usage information and exit")
 	getopt.Parse()
 	if *flagHelp {
-		fmt.Println(usageStr())
+		log.Errorln(usageStr())

Review comment:
       added log.Init()




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675767358



##########
File path: cache-config/t3c-check/t3c-check.go
##########
@@ -43,18 +43,18 @@ func main() {
 	flagHelp := getopt.BoolLong("help", 'h', "Print usage information and exit")
 	getopt.Parse()
 	if *flagHelp {
-		fmt.Println(usageStr())
+		log.Errorln(usageStr())
 		os.Exit(ExitCodeSuccess)
 	}
 
 	if len(os.Args) < 2 {
-		fmt.Fprintf(os.Stderr, "no command\n\n"+usageStr())
+		log.Errorf("no command\n\n" + usageStr())

Review comment:
       changed to single new line 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675163955



##########
File path: cache-config/t3c-generate/plugin/plugin.go
##########
@@ -59,7 +58,7 @@ type Plugins interface {
 func AddPlugin(priority uint64, funcs Funcs) {
 	_, filename, _, ok := runtime.Caller(1)
 	if !ok {
-		fmt.Println(time.Now().Format(time.RFC3339Nano) + " Error plugin.AddPlugin: runtime.Caller failed, can't get plugin names") // print, because this is called in init, loggers don't exist yet
+		log.Errorln(time.Now().Format(time.RFC3339Nano) + " Error plugin.AddPlugin: runtime.Caller failed, can't get plugin names")

Review comment:
       This needs to still be a Print, because like the comment said, the loggers haven't been initialized yet




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675697066



##########
File path: cache-config/t3cutil/t3cutil.go
##########
@@ -81,7 +81,7 @@ func NewLineFilter(str string) string {
 func ReadFile(f string) []byte {
 	data, err := ioutil.ReadFile(f)
 	if err != nil {
-		fmt.Println("Error reading file ", f)
+		log.Errorln("Error reading file ", f)

Review comment:
       removed unused func




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675169202



##########
File path: cache-config/t3c-apply/config/config.go
##########
@@ -329,25 +328,25 @@ func GetCfg() (Cfg, error) {
 	var tsHome = ""
 	if *tsHomePtr != "" {
 		tsHome = *tsHomePtr
-		fmt.Printf("set TSHome from command line: '%s'\n\n", TSHome)
+		log.Infof("set TSHome from command line: '%s'\n\n", TSHome)
 	}
 	if *tsHomePtr == "" { // evironment or rpm check.
 		tsHome = os.Getenv("TS_HOME") // check for the environment variable.
 		if tsHome != "" {
-			fmt.Printf("set TSHome from TS_HOME environment variable '%s'\n", TSHome)
+			log.Infof("set TSHome from TS_HOME environment variable '%s'\n", TSHome)
 		} else { // finally check using the config file listing from the rpm package.
 			tsHome = GetTSPackageHome()
 			if tsHome != "" {
-				fmt.Printf("set TSHome from the RPM config file  list '%s'\n", tsHome)
+				log.Infof("set TSHome from the RPM config file  list '%s'\n", tsHome)
 			} else {
-				fmt.Printf("no override for TSHome was found, using the configured default: '%s'\n", TSHome)
+				log.Infof("no override for TSHome was found, using the configured default: '%s'\n", TSHome)
 			}
 		}
 	}
 	if tsHome != "" {
 		TSHome = tsHome
 		TSConfigDir = tsHome + "/etc/trafficserver"
-		fmt.Printf("TSHome: %s, TSConfigDir: %s\n", TSHome, TSConfigDir)
+		log.Infof("TSHome: %s, TSConfigDir: %s\n", TSHome, TSConfigDir)

Review comment:
       All of these logs happen before the `log.InitCfg(cfg)` call below. Until that's called, the loggers don't exist. So these logs will never be written.
   
   The easiest solution here is probably to put the strings in an array, i.e.
   ```
   toInfoLog := []string{}
   ```
   And then e.g.
   ```
   	if *tsHomePtr != "" {
   		tsHome = *tsHomePtr
   		toInfoLog = append(toInfoLog, fmt.Sprintf("set TSHome from command line: '%s'", TSHome)
   	}
   ```
   
   And then, after the loggers are initialized:
   
   ```
   	if err = log.InitCfg(cfg); err != nil {
   		return Cfg{}, errors.New("Initializing loggers: " + err.Error() + "\n")
   	}
   
   	for msg := range toInfoLog {
   		log.Infoln(msg)
   	}
   ```

##########
File path: cache-config/t3c-check/t3c-check.go
##########
@@ -43,18 +43,18 @@ func main() {
 	flagHelp := getopt.BoolLong("help", 'h', "Print usage information and exit")
 	getopt.Parse()
 	if *flagHelp {
-		fmt.Println(usageStr())
+		log.Errorln(usageStr())
 		os.Exit(ExitCodeSuccess)
 	}
 
 	if len(os.Args) < 2 {
-		fmt.Fprintf(os.Stderr, "no command\n\n"+usageStr())
+		log.Errorf("no command\n\n" + usageStr())

Review comment:
       Needs changed to a single newline.

##########
File path: cache-config/t3c-generate/t3c-generate.go
##########
@@ -38,12 +37,12 @@ import (
 func main() {
 	cfg, err := config.GetCfg()
 	if err != nil {
-		fmt.Fprintf(os.Stderr, "Getting config: "+err.Error()+"\n")
+		log.Errorf("Getting config: %s\n", err.Error())

Review comment:
       This is a result of failing to initialize the config, so the loggers won't exist and this message will never be displayed.
   
   So it needs to `fmt.Print`, just no way around it.

##########
File path: cache-config/t3c-diff/t3c-diff.go
##########
@@ -36,31 +36,31 @@ func main() {
 	help := getopt.BoolLong("help", 'h', "Print usage info and exit")
 	getopt.ParseV2()
 	if *help {
-		fmt.Println(usageStr)
+		log.Errorln(usageStr)

Review comment:
       `t3c-diff` hasn't initialized the loggers, needs a `log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr)`

##########
File path: cache-config/t3c-apply/t3c-apply.go
##########
@@ -61,7 +60,7 @@ func main() {
 	var lock util.FileLock
 	cfg, err := config.GetCfg()
 	if err != nil {
-		fmt.Println(err)
+		log.Errorln(err)

Review comment:
       This error happened because the config was malformed, so the loggers won't exist.
   I think it needs to be a `fmt.Println`, there's just no way around it here. 
   
   And we need the error message, otherwise it's going to be impossible to figure out why it's failing.

##########
File path: cache-config/t3c/t3c.go
##########
@@ -48,18 +48,18 @@ func main() {
 	flagHelp := getopt.BoolLong("help", 'h', "Print usage information and exit")
 	getopt.Parse()
 	if *flagHelp {
-		fmt.Println(usageStr())
+		log.Errorln(usageStr())

Review comment:
       Loggers were never initialized, needs a call to `log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr)`

##########
File path: cache-config/t3c-generate/update-to-client/update-to-client.go
##########
@@ -32,26 +33,26 @@ import (
 
 func main() {
 	if len(os.Args) < 3 {
-		fmt.Fprintf(os.Stdout, usageStr())
+		log.Errorln(usageStr())

Review comment:
       This script hasn't initialized the loggers. You can either add a call to `log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr)`, or this one's probably fine not using the loggers, either way.
   
   This is a one-off development script, it never makes sense to run in a production system. It would be very unusual for anyone to want or need to run this thru log parsers.

##########
File path: cache-config/t3c-generate/config/config.go
##########
@@ -84,7 +83,7 @@ func GetCfg() (Cfg, error) {
 	getopt.Parse()
 
 	if *version {
-		fmt.Println(AppName + " v" + Version)
+		log.Errorln(AppName + " v" + Version)

Review comment:
       `t3c-generate` hasn't initialized the loggers yet here.
   You could either call `log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr)` immediately before this `log.Errorln` (since it exits anyway)
   
   Or, this one is probably ok to leave as a print. The goal of the loggers here is to make it possible for people to have log parsers, and not have them ever break. Since this message results from a call to `--version`, it should never be part of a production system that needs the result to run thru a log parser.

##########
File path: cache-config/t3c-request/config/config.go
##########
@@ -83,7 +82,7 @@ func InitConfig() (Cfg, error) {
 		Usage()
 	}
 	if *versionPtr == true {
-		fmt.Println(AppName + " v" + Version)
+		log.Errorln(AppName + " v" + Version)

Review comment:
       Like with the other app, the loggers haven't been initialized here yet. You can either call `log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr)`, or just print since it's highly unlikely`--version` calls will ever need run thru a log parser.

##########
File path: cache-config/t3c-update/config/config.go
##########
@@ -86,7 +85,7 @@ func InitConfig() (Cfg, error) {
 		Usage()
 	}
 	if *versionPtr == true {
-		fmt.Println(AppName + " v" + Version)
+		log.Errorln(AppName + " v" + Version)

Review comment:
       
   
   Like with the other app, the loggers haven't been initialized here yet. You can either call log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr), or just print since it's highly unlikely--version calls will ever need run thru a log parser.
   

##########
File path: cache-config/t3c-check/t3c-check.go
##########
@@ -43,18 +43,18 @@ func main() {
 	flagHelp := getopt.BoolLong("help", 'h', "Print usage information and exit")
 	getopt.Parse()
 	if *flagHelp {
-		fmt.Println(usageStr())
+		log.Errorln(usageStr())

Review comment:
       `t3c-check` hasn't initialized the loggers, so these log lines will never be printed. 
   
   Most apps use an interface, but that's probably overkill here. You can just initialize them all to stderr here:
   
   ```
   log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr)
   ```

##########
File path: cache-config/t3c-apply/config/config.go
##########
@@ -329,25 +328,25 @@ func GetCfg() (Cfg, error) {
 	var tsHome = ""
 	if *tsHomePtr != "" {
 		tsHome = *tsHomePtr
-		fmt.Printf("set TSHome from command line: '%s'\n\n", TSHome)
+		log.Infof("set TSHome from command line: '%s'\n\n", TSHome)

Review comment:
       Everything with multiple newlines needs changed to only have 1. E.g. this needs changed to 
   
   `log.Infof("set TSHome from command line: '%s'\n", TSHome)`
   
   Multiple newlines will result in log lines without the required prefix, which breaks people's log parsers.
   
   I made a PR to make that impossible by always prefixing every newline in the log function. But people didn't like that.

##########
File path: cache-config/t3cutil/t3cutil.go
##########
@@ -81,7 +81,7 @@ func NewLineFilter(str string) string {
 func ReadFile(f string) []byte {
 	data, err := ioutil.ReadFile(f)
 	if err != nil {
-		fmt.Println("Error reading file ", f)
+		log.Errorln("Error reading file ", f)

Review comment:
       Uhh...libraries should never log. We can't say whether loggers have been initialized, but if they haven't, someone is going to end up with their app exiting/crashing and it's going to be extremely confusing to figure out why.
   
   This function isn't used anywhere. Please just delete the function, if you don't mind.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675815912



##########
File path: cache-config/t3c-generate/t3c-generate.go
##########
@@ -38,12 +37,12 @@ import (
 func main() {
 	cfg, err := config.GetCfg()
 	if err != nil {
-		fmt.Fprintf(os.Stderr, "Getting config: "+err.Error()+"\n")
+		log.Errorf("Getting config: %s\n", err.Error())

Review comment:
       Changed back to Fprintf




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675163955



##########
File path: cache-config/t3c-generate/plugin/plugin.go
##########
@@ -59,7 +58,7 @@ type Plugins interface {
 func AddPlugin(priority uint64, funcs Funcs) {
 	_, filename, _, ok := runtime.Caller(1)
 	if !ok {
-		fmt.Println(time.Now().Format(time.RFC3339Nano) + " Error plugin.AddPlugin: runtime.Caller failed, can't get plugin names") // print, because this is called in init, loggers don't exist yet
+		log.Errorln(time.Now().Format(time.RFC3339Nano) + " Error plugin.AddPlugin: runtime.Caller failed, can't get plugin names")

Review comment:
       This needs to still be a Print, because the loggers haven't been initialized yet.
   
   The `AddPlugin` function is called by plugins in their `init` funcs. So there's really no way to reasonably initialize loggers before it's called, unfortunately.
   
   Fortunately, this error is extremely unusual and should almost never happen.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675701908



##########
File path: cache-config/t3c-generate/config/config.go
##########
@@ -84,7 +83,7 @@ func GetCfg() (Cfg, error) {
 	getopt.Parse()
 
 	if *version {
-		fmt.Println(AppName + " v" + Version)
+		log.Errorln(AppName + " v" + Version)

Review comment:
       Put back to print. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675772882



##########
File path: cache-config/t3c-apply/t3c-apply.go
##########
@@ -61,7 +60,7 @@ func main() {
 	var lock util.FileLock
 	cfg, err := config.GetCfg()
 	if err != nil {
-		fmt.Println(err)
+		log.Errorln(err)

Review comment:
       Put back to fmt.Println




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675701573



##########
File path: cache-config/t3c-request/config/config.go
##########
@@ -83,7 +82,7 @@ func InitConfig() (Cfg, error) {
 		Usage()
 	}
 	if *versionPtr == true {
-		fmt.Println(AppName + " v" + Version)
+		log.Errorln(AppName + " v" + Version)

Review comment:
       Put back to print. 

##########
File path: cache-config/t3c-update/config/config.go
##########
@@ -86,7 +85,7 @@ func InitConfig() (Cfg, error) {
 		Usage()
 	}
 	if *versionPtr == true {
-		fmt.Println(AppName + " v" + Version)
+		log.Errorln(AppName + " v" + Version)

Review comment:
       Put back to print. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c merged pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
rob05c merged pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r676822854



##########
File path: cache-config/t3c-apply/config/config.go
##########
@@ -329,25 +328,25 @@ func GetCfg() (Cfg, error) {
 	var tsHome = ""
 	if *tsHomePtr != "" {
 		tsHome = *tsHomePtr
-		fmt.Printf("set TSHome from command line: '%s'\n\n", TSHome)
+		log.Infof("set TSHome from command line: '%s'\n\n", TSHome)
 	}
 	if *tsHomePtr == "" { // evironment or rpm check.
 		tsHome = os.Getenv("TS_HOME") // check for the environment variable.
 		if tsHome != "" {
-			fmt.Printf("set TSHome from TS_HOME environment variable '%s'\n", TSHome)
+			log.Infof("set TSHome from TS_HOME environment variable '%s'\n", TSHome)
 		} else { // finally check using the config file listing from the rpm package.
 			tsHome = GetTSPackageHome()
 			if tsHome != "" {
-				fmt.Printf("set TSHome from the RPM config file  list '%s'\n", tsHome)
+				log.Infof("set TSHome from the RPM config file  list '%s'\n", tsHome)
 			} else {
-				fmt.Printf("no override for TSHome was found, using the configured default: '%s'\n", TSHome)
+				log.Infof("no override for TSHome was found, using the configured default: '%s'\n", TSHome)
 			}
 		}
 	}
 	if tsHome != "" {
 		TSHome = tsHome
 		TSConfigDir = tsHome + "/etc/trafficserver"
-		fmt.Printf("TSHome: %s, TSConfigDir: %s\n", TSHome, TSConfigDir)
+		log.Infof("TSHome: %s, TSConfigDir: %s\n", TSHome, TSConfigDir)

Review comment:
       Added array for info messages and for loop to print them out once logging is initialized. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675766918



##########
File path: cache-config/t3c-apply/config/config.go
##########
@@ -329,25 +328,25 @@ func GetCfg() (Cfg, error) {
 	var tsHome = ""
 	if *tsHomePtr != "" {
 		tsHome = *tsHomePtr
-		fmt.Printf("set TSHome from command line: '%s'\n\n", TSHome)
+		log.Infof("set TSHome from command line: '%s'\n\n", TSHome)

Review comment:
       Changed to single new line.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #6052: update print statements in t3c to use go logger library

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #6052:
URL: https://github.com/apache/trafficcontrol/pull/6052#discussion_r675672292



##########
File path: cache-config/t3c-generate/plugin/plugin.go
##########
@@ -59,7 +58,7 @@ type Plugins interface {
 func AddPlugin(priority uint64, funcs Funcs) {
 	_, filename, _, ok := runtime.Caller(1)
 	if !ok {
-		fmt.Println(time.Now().Format(time.RFC3339Nano) + " Error plugin.AddPlugin: runtime.Caller failed, can't get plugin names") // print, because this is called in init, loggers don't exist yet
+		log.Errorln(time.Now().Format(time.RFC3339Nano) + " Error plugin.AddPlugin: runtime.Caller failed, can't get plugin names")

Review comment:
       Changed back to print and also changed other log statement to print. Moved comment to top of func for readability. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org