Other: Add more extensive logging

This commit is contained in:
James Houlahan
2022-11-03 23:02:34 +01:00
parent 8bb60afabd
commit c548ba85fe
24 changed files with 405 additions and 81 deletions

View File

@ -17,6 +17,12 @@
package events
import (
"fmt"
"github.com/ProtonMail/proton-bridge/v2/internal/logging"
)
type UserAddressCreated struct {
eventBase
@ -25,6 +31,10 @@ type UserAddressCreated struct {
Email string
}
func (event UserAddressCreated) String() string {
return fmt.Sprintf("UserAddressCreated: UserID: %s, AddressID: %s, Email: %s", event.UserID, event.AddressID, logging.Sensitive(event.Email))
}
type UserAddressUpdated struct {
eventBase
@ -33,6 +43,10 @@ type UserAddressUpdated struct {
Email string
}
func (event UserAddressUpdated) String() string {
return fmt.Sprintf("UserAddressUpdated: UserID: %s, AddressID: %s, Email: %s", event.UserID, event.AddressID, logging.Sensitive(event.Email))
}
type UserAddressDeleted struct {
eventBase
@ -40,3 +54,7 @@ type UserAddressDeleted struct {
AddressID string
Email string
}
func (event UserAddressDeleted) String() string {
return fmt.Sprintf("UserAddressDeleted: UserID: %s, AddressID: %s, Email: %s", event.UserID, event.AddressID, logging.Sensitive(event.Email))
}

View File

@ -21,10 +21,22 @@ type TLSIssue struct {
eventBase
}
func (event TLSIssue) String() string {
return "TLSIssue"
}
type ConnStatusUp struct {
eventBase
}
func (event ConnStatusUp) String() string {
return "ConnStatusUp"
}
type ConnStatusDown struct {
eventBase
}
func (event ConnStatusDown) String() string {
return "ConnStatusDown"
}

View File

@ -17,8 +17,14 @@
package events
import "fmt"
type Error struct {
eventBase
Error error
}
func (event Error) String() string {
return fmt.Sprintf("Error: %s", event.Error)
}

View File

@ -17,6 +17,12 @@
package events
import (
"fmt"
"github.com/ProtonMail/proton-bridge/v2/internal/logging"
)
type UserLabelCreated struct {
eventBase
@ -25,6 +31,10 @@ type UserLabelCreated struct {
Name string
}
func (event UserLabelCreated) String() string {
return fmt.Sprintf("UserLabelCreated: UserID: %s, LabelID: %s, Name: %s", event.UserID, event.LabelID, logging.Sensitive(event.Name))
}
type UserLabelUpdated struct {
eventBase
@ -33,6 +43,10 @@ type UserLabelUpdated struct {
Name string
}
func (event UserLabelUpdated) String() string {
return fmt.Sprintf("UserLabelUpdated: UserID: %s, LabelID: %s, Name: %s", event.UserID, event.LabelID, logging.Sensitive(event.Name))
}
type UserLabelDeleted struct {
eventBase
@ -40,3 +54,7 @@ type UserLabelDeleted struct {
LabelID string
Name string
}
func (event UserLabelDeleted) String() string {
return fmt.Sprintf("UserLabelDeleted: UserID: %s, LabelID: %s, Name: %s", event.UserID, event.LabelID, logging.Sensitive(event.Name))
}

View File

@ -20,3 +20,7 @@ package events
type Raise struct {
eventBase
}
func (event Raise) String() string {
return "Raise"
}

View File

@ -17,7 +17,10 @@
package events
import "time"
import (
"fmt"
"time"
)
type SyncStarted struct {
eventBase
@ -25,6 +28,10 @@ type SyncStarted struct {
UserID string
}
func (event SyncStarted) String() string {
return fmt.Sprintf("SyncStarted: UserID: %s", event.UserID)
}
type SyncProgress struct {
eventBase
@ -34,15 +41,33 @@ type SyncProgress struct {
Remaining time.Duration
}
func (event SyncProgress) String() string {
return fmt.Sprintf(
"SyncProgress: UserID: %s, Progress: %f, Elapsed: %0.1fs, Remaining: %0.1fs",
event.UserID,
event.Progress,
event.Elapsed.Seconds(),
event.Remaining.Seconds(),
)
}
type SyncFinished struct {
eventBase
UserID string
}
func (event SyncFinished) String() string {
return fmt.Sprintf("SyncFinished: UserID: %s", event.UserID)
}
type SyncFailed struct {
eventBase
UserID string
Err error
Error error
}
func (event SyncFailed) String() string {
return fmt.Sprintf("SyncFailed: UserID: %s, Err: %s", event.UserID, event.Error)
}

View File

@ -17,7 +17,11 @@
package events
import "github.com/ProtonMail/proton-bridge/v2/internal/updater"
import (
"fmt"
"github.com/ProtonMail/proton-bridge/v2/internal/updater"
)
type UpdateAvailable struct {
eventBase
@ -27,16 +31,32 @@ type UpdateAvailable struct {
CanInstall bool
}
func (event UpdateAvailable) String() string {
return fmt.Sprintf("UpdateAvailable: Version %s, CanInstall %t", event.Version.Version, event.CanInstall)
}
type UpdateNotAvailable struct {
eventBase
}
func (event UpdateNotAvailable) String() string {
return "UpdateNotAvailable"
}
type UpdateInstalled struct {
eventBase
Version updater.VersionInfo
}
func (event UpdateInstalled) String() string {
return fmt.Sprintf("UpdateInstalled: Version %s", event.Version.Version)
}
type UpdateForced struct {
eventBase
}
func (event UpdateForced) String() string {
return "UpdateForced"
}

View File

@ -17,28 +17,49 @@
package events
import "github.com/ProtonMail/proton-bridge/v2/internal/vault"
import (
"fmt"
"github.com/ProtonMail/proton-bridge/v2/internal/vault"
)
type AllUsersLoaded struct {
eventBase
}
func (event AllUsersLoaded) String() string {
return "AllUsersLoaded"
}
type UserLoading struct {
eventBase
UserID string
}
func (event UserLoading) String() string {
return fmt.Sprintf("UserLoading: UserID: %s", event.UserID)
}
type UserLoadSuccess struct {
eventBase
UserID string
}
func (event UserLoadSuccess) String() string {
return fmt.Sprintf("UserLoadSuccess: UserID: %s", event.UserID)
}
type UserLoadFail struct {
eventBase
UserID string
Error error
}
func (event UserLoadFail) String() string {
return fmt.Sprintf("UserLoadFail: UserID: %s, Error: %s", event.UserID, event.Error)
}
type UserLoggedIn struct {
@ -47,33 +68,58 @@ type UserLoggedIn struct {
UserID string
}
func (event UserLoggedIn) String() string {
return fmt.Sprintf("UserLoggedIn: UserID: %s", event.UserID)
}
type UserLoggedOut struct {
eventBase
UserID string
}
func (event UserLoggedOut) String() string {
return fmt.Sprintf("UserLoggedOut: UserID: %s", event.UserID)
}
type UserDeauth struct {
eventBase
UserID string
}
func (event UserDeauth) String() string {
return fmt.Sprintf("UserDeauth: UserID: %s", event.UserID)
}
type UserDeleted struct {
eventBase
UserID string
}
func (event UserDeleted) String() string {
return fmt.Sprintf("UserDeleted: UserID: %s", event.UserID)
}
type UserChanged struct {
eventBase
UserID string
}
func (event UserChanged) String() string {
return fmt.Sprintf("UserChanged: UserID: %s", event.UserID)
}
type AddressModeChanged struct {
eventBase
UserID string
UserID string
AddressMode vault.AddressMode
}
func (event AddressModeChanged) String() string {
return fmt.Sprintf("AddressModeChanged: UserID: %s, AddressMode: %s", event.UserID, event.AddressMode)
}