﷽
Easylogging++ Node.js Binding
Easylogging++ Node.js binding provides ability to use efficient Easylogging++ to log important logs for your application.
Requirements
- Node 7+
Download
npm install --save easyloggingpp
Getting Started
const easyloggingpp = ;const ConfigType = easyloggingppConfigType;const Level = easyloggingppLevel;const logger = easyloggingpp; // register logger easyloggingpp; // alternatively you can use following to set default configurations// for future loggers as well as existing loggereasyloggingpp; logger;logger;var person = 'name': 'Adam' 'age': 960 logger; logger; easyloggingpp; // turn stack logging offlogger;logger;
Above will print something like:
Log
logger;logger;logger;logger;logger;logger;logger;
Log Formats
You can use advanced logging format specifiers.
logger.info('array %s', [1, 2, 3]);
Taken from utils.format
Format specifier | Explanation |
---|---|
%s | String. |
%d | Number (integer or floating point value). |
%i | Integer. |
%f | Floating point value. |
%j | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
%% | single percent sign ('%'). This does not consume an argument. |
%o
and %O
should not be used. Use %s
instead for better output.
Global Configuration
via File
easyloggingpp;
This will configure all the existing loggers and set this new configuation to default for future loggers.
All Levels
easyloggingpp;
or using array
easyloggingpp;
This will configure existing loggers but will not change future loggers.
Specific Level
easyloggingpp;
or using array
easyloggingpp;
This will configure existing loggers but will not change future loggers.
Logger Configuration
via File
const logger = easyloggingpp;logger;
All Levels
const logger = easyloggingpp; logger;
or using array
const logger = easyloggingpp;logger;
Specific Level
const logger = easyloggingpp; logger;
or using array
const logger = easyloggingpp;logger;
This will configure existing loggers but will not change future loggers.
Logging Flag
Add/Removeeasyloggingpp;easyloggingpp;
Profiler
You can use built-in profiler
logger;// some heavy taskfor var i = 0; i < 100000; ++i logger; // other tasks that will not be profiled// if needed or you could use finishProfiling directly logger;
Notes
Some notes for those who have previous experience with Easylogging++ (and for those who are absolutely new)
- Logs are written to
/dev/null
by default. You must configure viaeasyloggingpp.configureAllLoggers
at initialization. - Loggers are created automatically when you use
easyloggingpp.getLogger
. ColoredTerminalOutput
flag is set by default. You can unset it usingeasyloggingpp.removeFlag
- You can safely log with
Fatal
level asDisableApplicationAbortOnFatalLog
flag is set by default. You should not remove this flag. Read more
License
Copyright 2017-present Zuhd Web Services
Copyright 2017-present @abumusamq
https://github.com/zuhd-org
https://zuhd.org
https://muflihun.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.