2019-06-13 21:21:41 +00:00
|
|
|
package logfile
|
|
|
|
|
|
|
|
import (
|
2019-06-26 21:16:26 +00:00
|
|
|
"path/filepath"
|
2019-06-13 21:21:41 +00:00
|
|
|
)
|
|
|
|
|
2019-06-21 12:31:56 +00:00
|
|
|
// New returns a log file with basic functions for reading and writing data. The
|
|
|
|
// file extension of the logfile is taken into account to format the logfile
|
2019-06-19 17:18:01 +00:00
|
|
|
// into the correct format.
|
2019-06-26 21:16:26 +00:00
|
|
|
func New(logfile string) Logfile {
|
2019-06-28 11:04:04 +00:00
|
|
|
ext := filepath.Ext(logfile)
|
2019-06-26 21:16:26 +00:00
|
|
|
switch ext {
|
2019-06-28 11:04:04 +00:00
|
|
|
case ".csv":
|
|
|
|
return &csvLogfile{
|
|
|
|
logfile: logfile,
|
|
|
|
}
|
2019-06-26 21:16:26 +00:00
|
|
|
case ".json":
|
|
|
|
return &jsonLogfile{
|
|
|
|
logfile: logfile,
|
|
|
|
}
|
2019-07-03 16:46:19 +00:00
|
|
|
case ".xml":
|
|
|
|
return &xmlLogfile{
|
|
|
|
logfile: logfile,
|
|
|
|
}
|
2019-06-26 21:16:26 +00:00
|
|
|
default:
|
|
|
|
return &jsonLogfile{
|
|
|
|
logfile: logfile,
|
|
|
|
}
|
2019-06-15 13:45:35 +00:00
|
|
|
}
|
|
|
|
}
|