-
Notifications
You must be signed in to change notification settings - Fork 61
Logger
class Logger
A 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.
fun addAttribute(key: String, value: Any?)
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.
key | the key for this attribute |
value | the attribute 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.
key | the key for this tag |
value | the (non null) value of this tag |
documentation | (https://docs.datadoghq.com/tagging/#defining-tags) |
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.
tag | the (non null) tag |
documentation | (https://docs.datadoghq.com/tagging/#defining-tags) |
fun d(message: String, throwable: Throwable? = null, attributes: Map<String, Any?> = emptyMap())
Sends a Debug log message.
message | the message to be logged |
throwable | a (nullable) throwable to be logged with the message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
fun e(message: String, throwable: Throwable? = null, attributes: Map<String, Any?> = emptyMap())
Sends an Error log message.
message | the message to be logged |
throwable | a (nullable) throwable to be logged with the message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
fun i(message: String, throwable: Throwable? = null, attributes: Map<String, Any?> = emptyMap())
Sends an Info log message.
message | the message to be logged |
throwable | a (nullable) throwable to be logged with the message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
fun log(priority: Int, message: String, throwable: Throwable? = null, attributes: Map<String, Any?> = emptyMap())
Sends a log message.
priority | the priority level (must be one of the Android Log.* constants) |
message | the message to be logged |
throwable | a (nullable) throwable to be logged with the message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
fun log(priority: Int, message: String, errorKind: String?, errorMessage: String?, errorStacktrace: String?, attributes: Map<String, Any?> = emptyMap())
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
.
priority | the priority level (must be one of the Android Log.* constants) |
message | the message to be logged |
errorKind | the kind of error to be logged with the message |
errorMessage | the message from the error to be logged with this message |
errorStacktrace | the stack trace from the error to be logged with this message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
fun removeAttribute(key: String)
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.
key | the key of the attribute to remove |
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.
tag | the tag to remove |
fun removeTagsWithKey(key: String)
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.
key | the key of the tags to remove |
fun v(message: String, throwable: Throwable? = null, attributes: Map<String, Any?> = emptyMap())
Sends a VERBOSE log message.
message | the message to be logged |
throwable | a (nullable) throwable to be logged with the message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
fun w(message: String, throwable: Throwable? = null, attributes: Map<String, Any?> = emptyMap())
Sends a Warning log message.
message | the message to be logged |
throwable | a (nullable) throwable to be logged with the message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
fun wtf(message: String, throwable: Throwable? = null, attributes: Map<String, Any?> = emptyMap())
Sends an Assert log message.
message | the message to be logged |
throwable | a (nullable) throwable to be logged with the message |
attributes | a map of attributes to include only for this message. If an attribute with the same key already exist in this logger, it will be overridden (just for this message) |
- Datadog
- DatadogSite
- _InternalProxy
- InternalLogger
- SdkCore
- DatadogContext
- DeviceInfo
- DeviceType
- NetworkInfo
- ProcessInfo
- TimeInfo
- UserInfo
- Feature
- FeatureContextUpdateReceiver
- FeatureEventReceiver
- FeatureScope
- FeatureSdkCore
- StorageBackedFeature
- Request
- RequestFactory
- DataWriter
- EventBatchWriter
- EventType
- FeatureStorageConfiguration
- RawBatchEvent
- DataStoreHandler
- DataStoreReadCallback
- DataStoreWriteCallback
- InternalSdkCore
- SdkReference
- BackPressureMitigation
- BackPressureStrategy
- BatchProcessingLevel
- BatchSize
- Configuration
- HostsSanitizer
- UploadFrequency
- UploadSchedulerStrategy
- DataConstraints
- DatadogDataConstraints
- ThreadDump
- DefaultFirstPartyHostHeaderTypeResolver
- FirstPartyHostHeaderTypeResolver
- Deserializer
- BuildSdkVersionProvider
- JsonSerializer
- MethodCallSamplingRate
- PerformanceMetric
- TelemetryMetricType
- PersistenceStrategy
- Serializer
- DataStoreContent
- RateBasedSampler
- Sampler
- FlushableExecutorService
- EventMapper
- MapperSerializer
- NoOpEventMapper
- LogAttributes
- TrackingConsent
- TrackingConsentProviderCallback
- Encryption
- TracingHeaderType
- DdRumContentProvider
- GlobalRumMonitor
- Rum
- RumActionType
- RumAttributes
- RumConfiguration
- RumErrorSource
- RumMonitor
- RumPerformanceMetric
- RumResourceAttributesProvider
- RumResourceKind
- RumResourceMethod
- RumSessionListener
- _RumInternalProxy
- VitalsUpdateFrequency
- ViewEventMapper
- ResourceTiming
- AdvancedNetworkRumMonitor
- ResourceId
- RumResourceInputStream
- AcceptAllActivities
- AcceptAllDefaultFragment
- AcceptAllNavDestinations
- AcceptAllSupportFragments
- ActivityLifecycleTrackingStrategy
- ActivityViewTrackingStrategy
- ComponentPredicate
- FragmentViewTrackingStrategy
- InteractionPredicate
- MixedViewTrackingStrategy
- NavigationViewTrackingStrategy
- TrackingStrategy
- ViewAttributesProvider
- ViewTrackingStrategy
- DatadogDatabaseErrorHandler
- ActionEvent
- ErrorEvent
- LongTaskEvent
- ResourceEvent
- ViewEvent
- TelemetryConfigurationEvent
- TelemetryDebugEvent
- TelemetryErrorEvent
- ExtensionSupport
- ImagePrivacy
- MapperTypeWrapper
- SessionReplay
- SessionReplayConfiguration
- SessionReplayPrivacy
- MappingContext
- OptionSelectorDetector
- SystemInformation
- BaseAsyncBackgroundWireframeMapper
- BaseViewGroupMapper
- BaseWireframeMapper
- EditTextMapper
- TextViewMapper
- TraverseAllChildrenMapper
- WireframeMapper
- AndroidMDrawableToColorMapper
- AndroidQDrawableToColorMapper
- AsyncJobStatusCallback
- ColorStringFormatter
- DefaultColorStringFormatter
- DefaultViewBoundsResolver
- DefaultViewIdentifierResolver
- DrawableToColorMapper
- GlobalBounds
- ImageWireframeHelper
- LegacyDrawableToColorMapper
- ViewBoundsResolver
- ViewIdentifierResolver
- MobileSegment
- ResourceHashesEntry
- ResourceMetadata