utiller 1.0.28 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/utiller/index.js
CHANGED
|
@@ -163,17 +163,35 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
163
163
|
array.push.apply(array, (0, _toConsumableArray2["default"])(combine));
|
|
164
164
|
});
|
|
165
165
|
this.init();
|
|
166
|
+
this.env = "dev";
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
(0, _createClass2["default"])(Utiller, [{
|
|
169
170
|
key: "init",
|
|
170
171
|
value: function init() {// this.enrichZhTw();
|
|
171
172
|
}
|
|
173
|
+
}, {
|
|
174
|
+
key: "setEnvironment",
|
|
175
|
+
value: function setEnvironment(env) {
|
|
176
|
+
this.env = env;
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "getEnvironment",
|
|
180
|
+
value: function getEnvironment() {
|
|
181
|
+
return this.env;
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "isProductionEnvironment",
|
|
185
|
+
value: function isProductionEnvironment() {
|
|
186
|
+
return _lodash["default"].isEqual(this.env, "prod");
|
|
187
|
+
}
|
|
172
188
|
}, {
|
|
173
189
|
key: "appendInfo",
|
|
174
190
|
value: function appendInfo() {
|
|
175
191
|
var _console;
|
|
176
192
|
|
|
193
|
+
if (this.isProductionEnvironment()) return;
|
|
194
|
+
|
|
177
195
|
(_console = console).log.apply(_console, arguments);
|
|
178
196
|
}
|
|
179
197
|
}, {
|
|
@@ -181,6 +199,8 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
181
199
|
value: function appendError() {
|
|
182
200
|
var _console2;
|
|
183
201
|
|
|
202
|
+
if (this.isProductionEnvironment()) return;
|
|
203
|
+
|
|
184
204
|
(_console2 = console).error.apply(_console2, arguments);
|
|
185
205
|
}
|
|
186
206
|
}, {
|
|
@@ -1043,12 +1043,15 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1043
1043
|
}, {
|
|
1044
1044
|
key: "appendLog",
|
|
1045
1045
|
value: function appendLog(path, datas) {
|
|
1046
|
-
var _console, _console2;
|
|
1047
|
-
|
|
1048
1046
|
var isError = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1047
|
+
|
|
1048
|
+
if (!this.isProductionEnvironment()) {
|
|
1049
|
+
var _console, _console2;
|
|
1050
|
+
|
|
1051
|
+
isError ? (_console = console).error.apply(_console, (0, _toConsumableArray2["default"])(datas)) : (_console2 = console).log.apply(_console2, (0, _toConsumableArray2["default"])(datas));
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
var persistlog = "".concat(new Date(), " ").concat(isError ? "ERROR" : "LOG", " : ").concat(this.getLogString(datas));
|
|
1052
1055
|
this.appendFile(path, persistlog);
|
|
1053
1056
|
}
|
|
1054
1057
|
}, {
|
package/package.json
CHANGED