Skip to content

Commit

Permalink
chore: remove too many logging
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Oct 18, 2024
1 parent 71ba130 commit 456c163
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 29 deletions.
3 changes: 0 additions & 3 deletions internal/auth/mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (m mysqlRepo) GetByEmail(ctx context.Context, email string) (UserInfo, []by
return UserInfo{}, nil, gerr.ErrNotFound
}

m.log.Error("unexpected error happened", zap.Error(err))
return UserInfo{}, nil, errgo.Wrap(err, "gorm")
}

Expand Down Expand Up @@ -169,7 +168,6 @@ func (m mysqlRepo) CreateAccessToken(
Info: infoByte,
})
if err != nil {
m.log.Error("unexpected error happened", zap.Error(err))
return "", errgo.Wrap(err, "dal")
}

Expand All @@ -186,7 +184,6 @@ func (m mysqlRepo) ListAccessToken(ctx context.Context, userID model.UserID) ([]
Where(m.q.AccessToken.UserID.Eq(strconv.FormatUint(uint64(userID), 10)),
m.q.AccessToken.ExpiredAt.Gte(time.Now())).Find()
if err != nil {
m.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down
5 changes: 0 additions & 5 deletions internal/character/mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (r mysqlRepo) Get(ctx context.Context, id model.CharacterID) (model.Charact
return model.Character{}, gerr.ErrCharacterNotFound
}

r.log.Error("unexpected error happened", zap.Error(err))
return model.Character{}, errgo.Wrap(err, "dal")
}

Expand All @@ -60,7 +59,6 @@ func (r mysqlRepo) GetByIDs(
records, err := r.q.Character.WithContext(ctx).Preload(r.q.Character.Fields).
Where(r.q.Character.ID.In(slice.ToUint32(ids)...)).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand All @@ -80,7 +78,6 @@ func (r mysqlRepo) GetPersonRelated(
Order(r.q.Cast.SubjectID).
Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand All @@ -103,7 +100,6 @@ func (r mysqlRepo) GetSubjectRelated(
Where(r.q.CharacterSubjects.SubjectID.Eq(subjectID)).
Order(r.q.CharacterSubjects.CharacterID).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down Expand Up @@ -137,7 +133,6 @@ func (r mysqlRepo) GetSubjectRelationByIDs(
Find()

if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down
2 changes: 0 additions & 2 deletions internal/collections/infra/mysql_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ func (r mysqlRepo) ListSubjectCollection(

collections, err := q.Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down Expand Up @@ -799,7 +798,6 @@ func (r mysqlRepo) ListPersonCollection(

collections, err := q.Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down
5 changes: 0 additions & 5 deletions internal/person/mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ func (r mysqlRepo) Get(ctx context.Context, id model.PersonID) (model.Person, er
return model.Person{}, gerr.ErrNotFound
}

r.log.Error("unexpected error happened", zap.Error(err))

return model.Person{}, errgo.Wrap(err, "dal")
}

Expand All @@ -59,7 +57,6 @@ func (r mysqlRepo) GetSubjectRelated(
relations, err := r.q.PersonSubjects.WithContext(ctx).
Where(r.q.PersonSubjects.SubjectID.Eq(subjectID)).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand All @@ -84,7 +81,6 @@ func (r mysqlRepo) GetCharacterRelated(
Order(r.q.Cast.PersonID).
Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand All @@ -104,7 +100,6 @@ func (r mysqlRepo) GetByIDs(ctx context.Context, ids []model.PersonID) (map[mode
u, err := r.q.Person.WithContext(ctx).Joins(r.q.Person.Fields).
Where(r.q.Person.ID.In(ids...)).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down
2 changes: 1 addition & 1 deletion internal/revision/mysql_repo_episode.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (r mysqlRepo) GetEpisodeRelated(ctx context.Context, id model.RevisionID) (
r.log.Error("can't find revision text", zap.Uint32("id", revision.TextID))
return model.EpisodeRevision{}, gerr.ErrNotFound
}
r.log.Error("unexpected error happened", zap.Error(err))

return model.EpisodeRevision{}, errgo.Wrap(err, "dal")
}

Expand Down
6 changes: 2 additions & 4 deletions internal/revision/mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (r mysqlRepo) GetPersonRelated(ctx context.Context, id model.RevisionID) (m
if errors.Is(err, gorm.ErrRecordNotFound) {
return model.PersonRevision{}, gerr.ErrNotFound
}
r.log.Error("unexpected error happened", zap.Error(err))

return model.PersonRevision{}, errgo.Wrap(err, "dal")
}
data, err := r.q.RevisionText.WithContext(ctx).
Expand All @@ -95,7 +95,6 @@ func (r mysqlRepo) GetPersonRelated(ctx context.Context, id model.RevisionID) (m
return model.PersonRevision{}, gerr.ErrNotFound
}

r.log.Error("unexpected error happened", zap.Error(err))
return model.PersonRevision{}, errgo.Wrap(err, "dal")
}
return convertPersonRevisionDao(revision, data), nil
Expand Down Expand Up @@ -148,7 +147,7 @@ func (r mysqlRepo) GetCharacterRelated(ctx context.Context, id model.RevisionID)
r.log.Error("can't find revision text", zap.Uint32("id", revision.TextID))
return model.CharacterRevision{}, gerr.ErrNotFound
}
r.log.Error("unexpected error happened", zap.Error(err))

return model.CharacterRevision{}, errgo.Wrap(err, "dal")
}
return convertCharacterRevisionDao(revision, data), nil
Expand Down Expand Up @@ -199,7 +198,6 @@ func (r mysqlRepo) GetSubjectRelated(ctx context.Context, id model.RevisionID) (
return model.SubjectRevision{}, gerr.ErrNotFound
}

r.log.Error("unexpected error happened", zap.Error(err))
return model.SubjectRevision{}, errgo.Wrap(err, "dal")
}
return convertSubjectRevisionDao(revision, true), nil
Expand Down
8 changes: 0 additions & 8 deletions internal/subject/mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (r mysqlRepo) Get(ctx context.Context, id model.SubjectID, filter Filter) (
return model.Subject{}, fmt.Errorf("%w: %d", gerr.ErrNotFound, id)
}

r.log.Error("unexpected error happened", zap.Error(err))
return model.Subject{}, errgo.Wrap(err, "dal")
}

Expand Down Expand Up @@ -138,8 +137,6 @@ func (r mysqlRepo) GetPersonRelated(
Joins(r.q.PersonSubjects.Person).
Where(r.q.PersonSubjects.PersonID.Eq(personID)).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))

return nil, errgo.Wrap(err, "dal")
}

Expand All @@ -163,7 +160,6 @@ func (r mysqlRepo) GetCharacterRelated(
Joins(r.q.CharacterSubjects.Subject).
Where(r.q.CharacterSubjects.CharacterID.Eq(characterID)).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand All @@ -187,7 +183,6 @@ func (r mysqlRepo) GetSubjectRelated(
Joins(r.q.SubjectRelation.Subject).Where(r.q.SubjectRelation.SubjectID.Eq(subjectID)).
Order(r.q.SubjectRelation.Order).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down Expand Up @@ -217,7 +212,6 @@ func (r mysqlRepo) GetByIDs(

records, err := q.Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down Expand Up @@ -306,7 +300,6 @@ func (r mysqlRepo) Browse(

subjects, err := q.Limit(limit).Offset(offset).Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand All @@ -331,7 +324,6 @@ func (r mysqlRepo) GetActors(
Order(r.q.Cast.PersonID).
Find()
if err != nil {
r.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down
1 change: 0 additions & 1 deletion internal/user/mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func (m mysqlRepo) GetByName(ctx context.Context, username string) (User, error)
func (m mysqlRepo) GetByIDs(ctx context.Context, ids []model.UserID) (map[model.UserID]User, error) {
u, err := m.q.Member.WithContext(ctx).Where(m.q.Member.ID.In(ids...)).Find()
if err != nil {
m.log.Error("unexpected error happened", zap.Error(err))
return nil, errgo.Wrap(err, "dal")
}

Expand Down

0 comments on commit 456c163

Please sign in to comment.