-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ArtisanCloud/develop
Develop
- Loading branch information
Showing
8 changed files
with
272 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package zap | ||
|
||
import ( | ||
"github.com/ArtisanCloud/PowerLibs/object" | ||
"net/http" | ||
"os" | ||
"testing" | ||
) | ||
|
||
var strArtisanCloudPath = "/var/log/ArtisanCloud/PowerLibs" | ||
var strOutputPath = strArtisanCloudPath + "/output.log" | ||
var strErrorPath = strArtisanCloudPath + "/errors.log" | ||
|
||
func init() { | ||
err := initLogPath(strArtisanCloudPath, strOutputPath, strErrorPath) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func Test_Log_Info(t *testing.T) { | ||
logger, err := NewLogger(&object.HashMap{ | ||
"env": "test", | ||
"outputPath": strOutputPath, | ||
"errorPath": strErrorPath, | ||
}) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
logger.Info("test info", "response", &http.Response{}) | ||
|
||
} | ||
|
||
func initLogPath(path string, files ...string) (err error) { | ||
if _, err = os.Stat(path); os.IsNotExist(err) { | ||
err = os.MkdirAll(path, os.ModePerm) | ||
if err != nil { | ||
return err | ||
} | ||
} else if os.IsPermission(err) { | ||
return err | ||
} | ||
|
||
for _, fileName := range files { | ||
if _, err = os.Stat(fileName); os.IsNotExist(err) { | ||
_, err = os.Create(fileName) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
return err | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.