提交 10cbd7f6 编写于 作者: X Xin,Zhang 提交者: wu-sheng

Active the node.js agent log (#46)

* Active the node.js agent log

* add link
上级 64cd5efc
......@@ -4,4 +4,5 @@
* [Quick start](quick-start.md)
* [Install nodejs agent](install-agent.md)
* [Skywalking Backend Compatibility List](compatibility-list.md)
* FAQ
* [How to active agent log](how-to-active-agent-log.org)
* How to active Node.js Agent log
Node.js agent uses [[https://www.npmjs.com/package/debug][debug]] framework for output log, and your can active the log before you deploy application currently.
Note: *Node.js Agent only support that output the log to console currently.*
To active all level log, You should add following variable into environment variables before you deploy application.
#+BEGIN_SRC
DEBUG=skywalking:*
#+END_SRC
Maybe you just want to active *error* level log, That's fine, just add the variable into environment variables. The Agent support four log level: *debug* *info* *warn* *error* currently.
#+BEGIN_SRC
DEBUG=skywalking:error
#+END_SRC
......@@ -16,32 +16,36 @@
*/
const Logger = function() {
let _logger = require("debug");
this.debug = function(className, format, ...args) {
_logger(className + ":debug")(format, ...args);
};
this.info = function(className, format, ...args) {
_logger(className + ":info")(format, ...args);
};
this.warn = function(className, format, ...args) {
_logger(className + ":warn")(format, ...args);
};
this.error = function(className, format, ...args) {
_logger(className + ":error")(format, ...args);
};
let _debug = require("debug");
let _debugLogger = _debug("skywalking:debug");
let _infoLogger = _debug("skywalking:info");
let _warnLogger = _debug("skywalking:warn");
let _errorLogger = _debug("skywalking:error");
this.debug = function(className, format, ...args) {
_debugLogger("[%s] " + format, className, ...args);
};
this.info = function(className, format, ...args) {
_infoLogger("[%s] " + format, className, ...args);
};
this.warn = function(className, format, ...args) {
_warnLogger("[%s] " + format, className, ...args);
};
this.error = function(className, format, ...args) {
_errorLogger("[%s] " + format, className, ...args);
};
};
Logger.instance = null;
Logger.getInstance = function() {
if (this.instance === null) {
this.instance = new Logger();
}
return this.instance;
if (this.instance === null) {
this.instance = new Logger();
}
return this.instance;
};
module.exports = Logger.getInstance();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册