/
index.js
201 lines (177 loc) · 5.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import { deprecate } from '@ember/debug';
import { LOGGER } from '@ember/deprecated-features';
// Deliver message that the function is deprecated
const DEPRECATION_MESSAGE = 'Use of Ember.Logger is deprecated. Please use `console` for logging.';
const DEPRECATION_ID = 'ember-console.deprecate-logger';
const DEPRECATION_URL =
'https://deprecations.emberjs.com/v3.x#toc_use-console-rather-than-ember-logger';
/**
@module ember
*/
/**
Inside Ember-Metal, simply uses the methods from `imports.console`.
Override this to provide more robust logging functionality.
@class Logger
@deprecated Use 'console' instead
@namespace Ember
@public
*/
let DEPRECATED_LOGGER;
if (LOGGER) {
DEPRECATED_LOGGER = {
/**
Logs the arguments to the console.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
var foo = 1;
Ember.Logger.log('log value of foo:', foo);
// "log value of foo: 1" will be printed to the console
```
@method log
@for Ember.Logger
@param {*} arguments
@public
*/
log() {
deprecate(DEPRECATION_MESSAGE, false, {
id: DEPRECATION_ID,
until: '4.0.0',
url: DEPRECATION_URL,
for: 'ember-source',
since: {
enabled: '3.2.0',
},
});
return console.log(...arguments); // eslint-disable-line no-console
},
/**
Prints the arguments to the console with a warning icon.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
Ember.Logger.warn('Something happened!');
// "Something happened!" will be printed to the console with a warning icon.
```
@method warn
@for Ember.Logger
@param {*} arguments
@public
*/
warn() {
deprecate(DEPRECATION_MESSAGE, false, {
id: DEPRECATION_ID,
until: '4.0.0',
url: DEPRECATION_URL,
for: 'ember-source',
since: {
enabled: '3.2.0',
},
});
return console.warn(...arguments); // eslint-disable-line no-console
},
/**
Prints the arguments to the console with an error icon, red text and a stack trace.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
Ember.Logger.error('Danger! Danger!');
// "Danger! Danger!" will be printed to the console in red text.
```
@method error
@for Ember.Logger
@param {*} arguments
@public
*/
error() {
deprecate(DEPRECATION_MESSAGE, false, {
id: DEPRECATION_ID,
until: '4.0.0',
url: DEPRECATION_URL,
for: 'ember-source',
since: {
enabled: '3.2.0',
},
});
return console.error(...arguments); // eslint-disable-line no-console
},
/**
Logs the arguments to the console.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
var foo = 1;
Ember.Logger.info('log value of foo:', foo);
// "log value of foo: 1" will be printed to the console
```
@method info
@for Ember.Logger
@param {*} arguments
@public
*/
info() {
deprecate(DEPRECATION_MESSAGE, false, {
id: DEPRECATION_ID,
until: '4.0.0',
url: DEPRECATION_URL,
for: 'ember-source',
since: {
enabled: '3.2.0',
},
});
return console.info(...arguments); // eslint-disable-line no-console
},
/**
Logs the arguments to the console in blue text.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
var foo = 1;
Ember.Logger.debug('log value of foo:', foo);
// "log value of foo: 1" will be printed to the console
```
@method debug
@for Ember.Logger
@param {*} arguments
@public
*/
debug() {
deprecate(DEPRECATION_MESSAGE, false, {
id: DEPRECATION_ID,
until: '4.0.0',
url: DEPRECATION_URL,
for: 'ember-source',
since: {
enabled: '3.2.0',
},
});
/* eslint-disable no-console */
if (console.debug) {
return console.debug(...arguments);
}
return console.info(...arguments);
/* eslint-enable no-console */
},
/**
If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace.
```javascript
Ember.Logger.assert(true); // undefined
Ember.Logger.assert(true === false); // Throws an Assertion failed error.
Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message.
```
@method assert
@for Ember.Logger
@param {Boolean} bool Value to test
@param {String} message Assertion message on failed
@public
*/
assert() {
deprecate(DEPRECATION_MESSAGE, false, {
id: DEPRECATION_ID,
until: '4.0.0',
url: DEPRECATION_URL,
for: 'ember-source',
since: {
enabled: '3.2.0',
},
});
return console.assert(...arguments); // eslint-disable-line no-console
},
};
}
export default DEPRECATED_LOGGER;