Class BizLogger
java.lang.Object
com.onenetwork.platform.tools.log.BizLogger
public final class BizLogger
extends java.lang.Object
BizLogger (short for "Business Logger") is used by modules to send
textual messages and other structured data to a NoSQL data store which
can be searched by a business user later. This data is encapsulated
in a
BizLoggerDoc
.
For example, if you have an engine which automatically generates
orders (i.e. replenishment), you might log information about what items
and sites your are executing against, what orders you generated, and information
explaining why you placed the orders.
Each time a BizLoggerDoc is logged through this API, up to two copies are created.
First, one copy is always sent to an "Instance/ValueChain" index, which allows
the Value Chain admin to query for a history of all logs produced by their instance.
Second, if entName is non-null, a copy is sent to an "Enterprise" index, which allows
an Enterprise admin to query for a history of all logs produced across instances
for their enterprise. Module authors should be cognizant of this, ensuring that they
do not put any data which a particular Enterprise should not see into a BizLoggerDoc
which is logged to that Enterprise.
All log methods (debug, info, warn, error) are handled asynchronously, meaning
your application code will not be adversely affected by any latency (or outage) of the NoSQL data
store. By the same token, delivery is not 100% guaranteed, so modules should not assume that
a commit of the surrounding relational database transaction implies successful completion
of the BizLoggerDoc posting.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BizLogger.Level
Enum for log level. -
Method Summary
Modifier and Type Method Description static void
debug(BizLoggerDoc doc, java.lang.String entName, PlatformUserContext ctx)
Likeinfo(BizLoggerDoc, String, PlatformUserContext)
, but has a level of "debug", meaning "relevant only for detailed debugging".static void
error(BizLoggerDoc doc, java.lang.String entName, PlatformUserContext ctx)
Likeinfo(BizLoggerDoc, String, PlatformUserContext)
, but has a level of "error", meaning "a serious business processing problem or data inconsistency was detected".static void
info(BizLoggerDoc doc, java.lang.String entName, PlatformUserContext ctx)
Asynchronously logs the given BizLoggerDoc to the Instance/ValueChain index, as well as the Enterprise index if entName is not null.static void
log(BizLogger.Level level, BizLoggerDoc doc, java.lang.String entName, PlatformUserContext ctx)
Convenience method withBizLogger.Level
as a parameterstatic BizLoggerDoc
newDoc(java.lang.String type, java.lang.String version)
Creates a new, empty BizLoggerDoc which can be populated then posted through one of the log methods (debug, info, warn, error).static void
warn(BizLoggerDoc doc, java.lang.String entName, PlatformUserContext ctx)
Likeinfo(BizLoggerDoc, String, PlatformUserContext)
, but has a level of "warn", meaning "may indicate a business processing problem or data inconsistency".
-
Method Details
-
newDoc
Creates a new, empty BizLoggerDoc which can be populated then posted through one of the log methods (debug, info, warn, error).- Parameters:
type
- module-specific BizLoggerDoc type. Can be any string, but is strongly recommended that you prefix it with a module prefix, e.g. "ZBKS.BookSale".version
- version of the module-specific BizLoggerDoc. Recommend starting from 1.0 and increasing, but it is left to the caller to decide.- Returns:
- a fresh BizLoggerDoc which can be posted through one of the log methods (debug, info, warn, error)
-
info
Asynchronously logs the given BizLoggerDoc to the Instance/ValueChain index, as well as the Enterprise index if entName is not null. This log will have a level of "info", meaning "normal operation".- Parameters:
doc
- document to post.entName
- enterprise to whom the document should be postedctx
- caller's context
-
debug
Likeinfo(BizLoggerDoc, String, PlatformUserContext)
, but has a level of "debug", meaning "relevant only for detailed debugging". -
warn
Likeinfo(BizLoggerDoc, String, PlatformUserContext)
, but has a level of "warn", meaning "may indicate a business processing problem or data inconsistency". -
error
Likeinfo(BizLoggerDoc, String, PlatformUserContext)
, but has a level of "error", meaning "a serious business processing problem or data inconsistency was detected". -
log
public static void log(BizLogger.Level level, BizLoggerDoc doc, java.lang.String entName, PlatformUserContext ctx)Convenience method withBizLogger.Level
as a parameter
-