@@ -10,8 +10,6 @@ import (
10
10
"go.mongodb.org/mongo-driver/bson"
11
11
"go.mongodb.org/mongo-driver/mongo"
12
12
"go.mongodb.org/mongo-driver/mongo/options"
13
- "go.uber.org/zap"
14
- "go.uber.org/zap/zapcore"
15
13
)
16
14
17
15
var log = logger .GetLogger ()
@@ -33,7 +31,7 @@ func NewCrawlerMongodbRepository(ctx context.Context) CrawlerMongodbRepository {
33
31
opts := options .Client ().ApplyURI (endpoint )
34
32
client , err := mongo .Connect (ctx , opts )
35
33
if err != nil {
36
- log .Error ("error connecting to mongodb" , zap. Field { Type : zapcore . StringType , String : err . Error ()} )
34
+ log .Error ("error connecting to mongodb" , logger . FieldError ( err ) )
37
35
}
38
36
39
37
return CrawlerMongodbRepository {client }
@@ -51,7 +49,7 @@ func (c CrawlerMongodbRepository) Insert(ctx context.Context, uri string, depth
51
49
}
52
50
_ , err := c .getCollection ().InsertOne (ctx , pageDataInfo )
53
51
if err != nil {
54
- log .Error ("error while inserting new data into collection" , zap. Field { Type : zapcore . StringType , String : err . Error ()} )
52
+ log .Error ("error while inserting new data into collection" , logger . FieldError ( err ) )
55
53
56
54
return err
57
55
}
@@ -64,7 +62,7 @@ func (c CrawlerMongodbRepository) Find(ctx context.Context, uri string, depth ui
64
62
pageDataInfo := pageDataInfo {}
65
63
err := c .getCollection ().FindOne (ctx , filter ).Decode (& pageDataInfo )
66
64
if err != nil {
67
- log .Error ("error while fetching data from collection" , zap. Field { Type : zapcore . StringType , String : err . Error ()} )
65
+ log .Error ("error while fetching data from collection" , logger . FieldError ( err ) )
68
66
69
67
return nil , err
70
68
}
0 commit comments