Skip to content

Commit

Permalink
Merge pull request #531 from brotherlogic/bounce
Browse files Browse the repository at this point in the history
bounce
  • Loading branch information
brotherlogic committed Aug 18, 2020
2 parents 3e9717e + d0e82c0 commit a37862b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ func (s *GoServer) hasScratch() bool {

}

func (s *GoServer) DLog(text string) {
if s.dlogHandle != nil {
s.dlogHandle.WriteString(fmt.Sprintf("%v %v\n", time.Now().Unix(), text))
}
}

func (s *GoServer) prepDLog() {
if s.hasScratch() {
filename := fmt.Sprintf("/media/scratch/dlogs/%v/%v.logs", s.Registry.GetName(), time.Now().Unix())
os.MkdirAll(fmt.Sprintf("/media/scratch/dlogs/%v-dlogs/", s.Registry.GetName()), 0777)
os.MkdirAll(fmt.Sprintf("/media/scratch/dlogs/%v/", s.Registry.GetName()), 0777)
fhandle, err := os.Create(filename)
if err != nil {
s.Log(fmt.Sprintf("Unable to open file: %v", err))
Expand Down
5 changes: 5 additions & 0 deletions goserverapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,11 @@ func (s *GoServer) SendCrash(ctx context.Context, crashText string, ctype pbbs.C

//PLog a simple string message with priority
func (s *GoServer) PLog(message string, level pbd.LogLevel) {
if !s.SkipLog {
go func() {
s.DLog(message)
}()
}
go func() {
if !s.SkipLog && s.Registry != nil {
ctx, cancel := utils.ManualContext(s.Registry.GetName(), "logging", time.Second, false)
Expand Down

0 comments on commit a37862b

Please sign in to comment.