Fixing the logger initialization to sms.go

Using golang init is creating log files in various folders
when tests are run.
Moved to Init which is called my server initialization.

Issue-ID: AAF-148
Change-Id: Ia05fa1ed1841fd6a98852329ab031372f6489ad6
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
diff --git a/sms-service/src/sms/log/logger.go b/sms-service/src/sms/log/logger.go
index ad7d388..8d116dd 100644
--- a/sms-service/src/sms/log/logger.go
+++ b/sms-service/src/sms/log/logger.go
@@ -25,18 +25,19 @@
 var warnLogger *log.Logger
 var infoLogger *log.Logger
 
-func init() {
-	f, err := os.OpenFile("sms.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
+// Init will be called by sms.go before any other packages use it
+func Init(filePath string) {
+	f, err := os.Create(filePath)
 	if err != nil {
 		log.Println("Unable to create a log file")
 		log.Println(err)
-		errLogger = log.New(os.Stderr, "ERROR: ", log.Lshortfile)
-		warnLogger = log.New(os.Stdout, "WARNING: ", log.Lshortfile)
-		infoLogger = log.New(os.Stdout, "INFO: ", log.Lshortfile)
+		errLogger = log.New(os.Stderr, "ERROR: ", log.Lshortfile|log.LstdFlags)
+		warnLogger = log.New(os.Stdout, "WARNING: ", log.Lshortfile|log.LstdFlags)
+		infoLogger = log.New(os.Stdout, "INFO: ", log.Lshortfile|log.LstdFlags)
 	} else {
-		errLogger = log.New(f, "ERROR: ", log.Lshortfile)
-		warnLogger = log.New(f, "WARNING: ", log.Lshortfile)
-		infoLogger = log.New(f, "INFO: ", log.Lshortfile)
+		errLogger = log.New(f, "ERROR: ", log.Lshortfile|log.LstdFlags)
+		warnLogger = log.New(f, "WARNING: ", log.Lshortfile|log.LstdFlags)
+		infoLogger = log.New(f, "INFO: ", log.Lshortfile|log.LstdFlags)
 	}
 }
 
diff --git a/sms-service/src/sms/sms.go b/sms-service/src/sms/sms.go
index b117bbc..eb0bebc 100644
--- a/sms-service/src/sms/sms.go
+++ b/sms-service/src/sms/sms.go
@@ -24,9 +24,13 @@
 	smsbackend "sms/backend"
 	smsconfig "sms/config"
 	smshandler "sms/handler"
+	smslogger "sms/log"
 )
 
 func main() {
+	// Initialize logger
+	smslogger.Init("sms.log")
+
 	// Read Configuration File
 	smsConf, err := smsconfig.ReadConfigFile("smsconfig.json")
 	if err != nil {