@@ -12,8 +12,6 @@ const {
12
12
toPairs
13
13
} = require ( 'lodash/fp' ) ;
14
14
15
- const log = require ( '@serverless/utils/log' ) . log ;
16
-
17
15
const SQS = require ( './sqs' ) ;
18
16
19
17
const OFFLINE_OPTION = 'serverless-offline' ;
@@ -32,15 +30,21 @@ const defaultOptions = {
32
30
const omitUndefined = omitBy ( isUndefined ) ;
33
31
34
32
class ServerlessOfflineSQS {
35
- constructor ( serverless , cliOptions ) {
33
+ constructor ( serverless , cliOptions , { log } = { } ) {
36
34
this . cliOptions = null ;
37
35
this . options = null ;
36
+ this . log = null ;
38
37
this . sqs = null ;
39
38
this . lambda = null ;
40
39
this . serverless = null ;
41
40
42
41
this . cliOptions = cliOptions ;
43
42
this . serverless = serverless ;
43
+ this . log = log || {
44
+ debug : console . debug . bind ( console ) ,
45
+ notice : console . log . bind ( console ) ,
46
+ warning : console . warn . bind ( console )
47
+ } ;
44
48
45
49
this . hooks = {
46
50
'offline:start:init' : this . start . bind ( this ) ,
@@ -67,9 +71,7 @@ class ServerlessOfflineSQS {
67
71
68
72
await Promise . all ( eventModules ) ;
69
73
70
- this . serverless . cli . log (
71
- `Starting Offline SQS at stage ${ this . options . stage } (${ this . options . region } )`
72
- ) ;
74
+ this . log . notice ( `Starting Offline SQS at stage ${ this . options . stage } (${ this . options . region } )` ) ;
73
75
}
74
76
75
77
ready ( ) {
@@ -83,7 +85,7 @@ class ServerlessOfflineSQS {
83
85
84
86
signals . map ( signal =>
85
87
process . on ( signal , async ( ) => {
86
- this . serverless . cli . log ( `Got ${ signal } signal. Offline Halting...` ) ;
88
+ this . log . notice ( `Got ${ signal } signal. Offline Halting...` ) ;
87
89
88
90
await this . end ( ) ;
89
91
} )
@@ -100,7 +102,7 @@ class ServerlessOfflineSQS {
100
102
return ;
101
103
}
102
104
103
- this . serverless . cli . log ( 'Halting offline server' ) ;
105
+ this . log . notice ( 'Halting offline server' ) ;
104
106
105
107
const eventModules = [ ] ;
106
108
@@ -129,7 +131,7 @@ class ServerlessOfflineSQS {
129
131
async _createSqs ( events , skipStart ) {
130
132
const resources = this . _getResources ( ) ;
131
133
132
- this . sqs = new SQS ( this . lambda , resources , this . options ) ;
134
+ this . sqs = new SQS ( this . lambda , resources , this . options , this . log ) ;
133
135
134
136
await this . sqs . create ( events ) ;
135
137
@@ -155,7 +157,7 @@ class ServerlessOfflineSQS {
155
157
omitUndefined ( this . cliOptions )
156
158
) ;
157
159
158
- log . debug ( 'options:' , this . options ) ;
160
+ this . log . debug ( 'sqs options:' , this . options ) ;
159
161
}
160
162
161
163
_getEvents ( ) {
0 commit comments