-
public final class LoggerA class enabling Datadog logging features.
It allows you to create a specific context (automatic information, custom attributes, tags) that will be embedded in all logs sent through this logger.
You can have multiple loggers configured in your application, each with their own settings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classLogger.BuilderA Builder class for a Logger.
-
Method Summary
Modifier and Type Method Description final Unitv(String message, Throwable throwable, Map<String, Object> attributes)Sends a VERBOSE log message. final Unitv(String message, Throwable throwable)Sends a VERBOSE log message. final Unitv(String message)Sends a VERBOSE log message. final Unitd(String message, Throwable throwable, Map<String, Object> attributes)Sends a Debug log message. final Unitd(String message, Throwable throwable)Sends a Debug log message. final Unitd(String message)Sends a Debug log message. final Uniti(String message, Throwable throwable, Map<String, Object> attributes)Sends an Info log message. final Uniti(String message, Throwable throwable)Sends an Info log message. final Uniti(String message)Sends an Info log message. final Unitw(String message, Throwable throwable, Map<String, Object> attributes)Sends a Warning log message. final Unitw(String message, Throwable throwable)Sends a Warning log message. final Unitw(String message)Sends a Warning log message. final Unite(String message, Throwable throwable, Map<String, Object> attributes)Sends an Error log message. final Unite(String message, Throwable throwable)Sends an Error log message. final Unite(String message)Sends an Error log message. final Unitwtf(String message, Throwable throwable, Map<String, Object> attributes)Sends an Assert log message. final Unitwtf(String message, Throwable throwable)Sends an Assert log message. final Unitwtf(String message)Sends an Assert log message. final Unitlog(Integer priority, String message, Throwable throwable, Map<String, Object> attributes)Sends a log message. final Unitlog(Integer priority, String message, Throwable throwable)Sends a log message. final Unitlog(Integer priority, String message)Sends a log message. final Unitlog(Integer priority, String message, String errorKind, String errorMessage, String errorStacktrace, Map<String, Object> attributes)Sends a log message with strings for error information. final Unitlog(Integer priority, String message, String errorKind, String errorMessage, String errorStacktrace)Sends a log message with strings for error information. final UnitaddAttribute(String key, Boolean value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, Integer value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, Long value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, Float value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, Double value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, String value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, Date value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, JsonObject value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, JsonArray value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, JSONObject value)Add a custom attribute to all future logs sent by this logger. final UnitaddAttribute(String key, JSONArray value)Add a custom attribute to all future logs sent by this logger. final UnitremoveAttribute(String key)Remove a custom attribute from all future logs sent by this logger. final UnitaddTag(String key, String value)Add a tag to all future logs sent by this logger. final UnitaddTag(String tag)Add a tag to all future logs sent by this logger. final UnitremoveTag(String tag)Remove a tag from all future logs sent by this logger. final UnitremoveTagsWithKey(String key)Remove all tags with the given key from all future logs sent by this logger. -
-
Method Detail
-
v
@JvmOverloads() final Unit v(String message, Throwable throwable, Map<String, Object> attributes)
Sends a VERBOSE log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the messageattributes- a map of attributes to include only for this message.
-
v
@JvmOverloads() final Unit v(String message, Throwable throwable)
Sends a VERBOSE log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the message
-
v
@JvmOverloads() final Unit v(String message)
Sends a VERBOSE log message.
- Parameters:
message- the message to be logged
-
d
@JvmOverloads() final Unit d(String message, Throwable throwable, Map<String, Object> attributes)
Sends a Debug log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the messageattributes- a map of attributes to include only for this message.
-
d
@JvmOverloads() final Unit d(String message, Throwable throwable)
Sends a Debug log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the message
-
d
@JvmOverloads() final Unit d(String message)
Sends a Debug log message.
- Parameters:
message- the message to be logged
-
i
@JvmOverloads() final Unit i(String message, Throwable throwable, Map<String, Object> attributes)
Sends an Info log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the messageattributes- a map of attributes to include only for this message.
-
i
@JvmOverloads() final Unit i(String message, Throwable throwable)
Sends an Info log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the message
-
i
@JvmOverloads() final Unit i(String message)
Sends an Info log message.
- Parameters:
message- the message to be logged
-
w
@JvmOverloads() final Unit w(String message, Throwable throwable, Map<String, Object> attributes)
Sends a Warning log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the messageattributes- a map of attributes to include only for this message.
-
w
@JvmOverloads() final Unit w(String message, Throwable throwable)
Sends a Warning log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the message
-
w
@JvmOverloads() final Unit w(String message)
Sends a Warning log message.
- Parameters:
message- the message to be logged
-
e
@JvmOverloads() final Unit e(String message, Throwable throwable, Map<String, Object> attributes)
Sends an Error log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the messageattributes- a map of attributes to include only for this message.
-
e
@JvmOverloads() final Unit e(String message, Throwable throwable)
Sends an Error log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the message
-
e
@JvmOverloads() final Unit e(String message)
Sends an Error log message.
- Parameters:
message- the message to be logged
-
wtf
@JvmOverloads() final Unit wtf(String message, Throwable throwable, Map<String, Object> attributes)
Sends an Assert log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the messageattributes- a map of attributes to include only for this message.
-
wtf
@JvmOverloads() final Unit wtf(String message, Throwable throwable)
Sends an Assert log message.
- Parameters:
message- the message to be loggedthrowable- a (nullable) throwable to be logged with the message
-
wtf
@JvmOverloads() final Unit wtf(String message)
Sends an Assert log message.
- Parameters:
message- the message to be logged
-
log
@JvmOverloads() final Unit log(Integer priority, String message, Throwable throwable, Map<String, Object> attributes)
Sends a log message.
- Parameters:
priority- the priority level (must be one of the Android Log.message- the message to be loggedthrowable- a (nullable) throwable to be logged with the messageattributes- a map of attributes to include only for this message.
-
log
@JvmOverloads() final Unit log(Integer priority, String message, Throwable throwable)
Sends a log message.
- Parameters:
priority- the priority level (must be one of the Android Log.message- the message to be loggedthrowable- a (nullable) throwable to be logged with the message
-
log
@JvmOverloads() final Unit log(Integer priority, String message)
Sends a log message.
- Parameters:
priority- the priority level (must be one of the Android Log.message- the message to be logged
-
log
@JvmOverloads() final Unit log(Integer priority, String message, String errorKind, String errorMessage, String errorStacktrace, Map<String, Object> attributes)
Sends a log message with strings for error information.
This method is meant for non-native or cross platform frameworks (such as React Native or Flutter) to send error information to Datadog. Although it can be used directly, it is recommended to use other methods declared on
Logger.- Parameters:
priority- the priority level (must be one of the Android Log.message- the message to be loggederrorKind- the kind of error to be logged with the messageerrorMessage- the message from the error to be logged with this messageerrorStacktrace- the stack trace from the error to be logged with this messageattributes- a map of attributes to include only for this message.
-
log
@JvmOverloads() final Unit log(Integer priority, String message, String errorKind, String errorMessage, String errorStacktrace)
Sends a log message with strings for error information.
This method is meant for non-native or cross platform frameworks (such as React Native or Flutter) to send error information to Datadog. Although it can be used directly, it is recommended to use other methods declared on
Logger.- Parameters:
priority- the priority level (must be one of the Android Log.message- the message to be loggederrorKind- the kind of error to be logged with the messageerrorMessage- the message from the error to be logged with this messageerrorStacktrace- the stack trace from the error to be logged with this message
-
addAttribute
final Unit addAttribute(String key, Boolean value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the boolean value of this attribute
-
addAttribute
final Unit addAttribute(String key, Integer value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the integer value of this attribute
-
addAttribute
final Unit addAttribute(String key, Long value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the long value of this attribute
-
addAttribute
final Unit addAttribute(String key, Float value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the float value of this attribute
-
addAttribute
final Unit addAttribute(String key, Double value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the double value of this attribute
-
addAttribute
final Unit addAttribute(String key, String value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the (nullable) String value of this attribute
-
addAttribute
final Unit addAttribute(String key, Date value)
Add a custom attribute to all future logs sent by this logger.
- Parameters:
key- the key for this attributevalue- the (nullable) Date value of this attribute
-
addAttribute
final Unit addAttribute(String key, JsonObject value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the (nullable) JsonObject value of this attribute
-
addAttribute
final Unit addAttribute(String key, JsonArray value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the (nullable) JsonArray value of this attribute
-
addAttribute
final Unit addAttribute(String key, JSONObject value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the (nullable) JSONObject value of this attribute
-
addAttribute
final Unit addAttribute(String key, JSONArray value)
Add a custom attribute to all future logs sent by this logger.
Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.
- Parameters:
key- the key for this attributevalue- the (nullable) JSONArray value of this attribute
-
removeAttribute
final Unit removeAttribute(String key)
Remove a custom attribute from all future logs sent by this logger. Previous logs won't lose the attribute value associated with this key if they were created prior to this call.
- Parameters:
key- the key of the attribute to remove
-
addTag
final Unit addTag(String key, String value)
Add a tag to all future logs sent by this logger. The tag will take the form "key:value".
Tags must start with a letter and after that may contain the following characters: Alphanumerics, Underscores, Minuses, Colons, Periods, Slashes. Other special characters are converted to underscores. Tags must be lowercase, and can be at most 200 characters. If the tag you provide is longer, only the first 200 characters will be used.
- Parameters:
key- the key for this tagvalue- the (non null) value of this tag
-
addTag
final Unit addTag(String tag)
Add a tag to all future logs sent by this logger.
Tags must start with a letter and after that may contain the following characters: Alphanumerics, Underscores, Minuses, Colons, Periods, Slashes. Other special characters are converted to underscores. Tags must be lowercase, and can be at most 200 characters. If the tag you provide is longer, only the first 200 characters will be used.
- Parameters:
tag- the (non null) tag
-
removeTag
final Unit removeTag(String tag)
Remove a tag from all future logs sent by this logger. Previous logs won't lose the this tag if they were created prior to this call.
- Parameters:
tag- the tag to remove
-
removeTagsWithKey
final Unit removeTagsWithKey(String key)
Remove all tags with the given key from all future logs sent by this logger. Previous logs won't lose the this tag if they were created prior to this call.
- Parameters:
key- the key of the tags to remove
-
-
-
-