@big-brains/kendra
v0.0.4
Published
Lightweight utilities which at the kendra!
Downloads
18
Readme
UNDER DEVELOPMENT: NOT READY FOR PRODUCTION.
Environment variables:
- MONGO: If you want to use mongodb.
- KENDRA: RabbitMq or any ampq compitible queue connection string.
- LOG_LEVEL: Logging level, default: 4.
- LOG_EXCHANGE: Exchange to which the logs must be published. Default: logs (no warning is shown if not provided.)
usage:
const kendra = require('@big-brains/kendra');
kendra('component-or-service-name')
.then(({
rpc: {
on,
call,
broadcast,
newsOn
},
log: {
get
},
dbAction
}) => {
const {
trace,
debug,
info,
warn,
error,
fatal,
} = get('subcomponent-or-subsection-name');
// DO YOUR THING!
});A word on log level
RANK Level Description
6 TRACE Designates finer-grained informational events than the DEBUG.
5 DEBUG Designates fine-grained informational events that are most
useful to debug an application.
4 INFO Designates informational messages that highlight the progress
of the application at coarse-grained level.
3 WARN Designates potentially harmful situations.
2 ERROR Designates error events that might still allow the application to continue running.
1 FATAL Designates very severe error events that will presumably lead the application to abort.
0 OFF The highest possible rank and is intended to turn off logging.
TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF
Example:
If log level is set to 4, then FATAL, ERROR, WARN and INFO are enabled.
Same way, if log level is set to 2, then FATAL and ERROR are enabled.usage (log):
/* Assume its just below DO YOUR THING! (see above usage example) */
trace('message in string', { any: { mata: 'data can go here' }});
Error index:
FATAL
- 100: Set KENDRA environment variable to RabbitMq or any ampq compitible queue connection string to initialize kendra. Exiting.
- 101: Set MONGO environment variable to use dbAction. Exiting.
- 102: Some error in module initialization state machine. Exiting.
(above errors will not be available on ampq logs.)
- 103: MONGO MUST have a connection string with inline db, db MUST provided at {{db}}. Eg. mongodb://127.0.0.1:27017/{{db}}
ERROR
- 200: Failed to execute dbAction (along with actual error)
WARN
- 300: LOG_LEVEL environment variable unset. Default log level set to 4 (info)
- 301: Connection was closed. New connection will be created in next attempt. All happened because of
INFO
- 401: New connection created
Happy coding!
