Giter Site home page Giter Site logo

tencentlog's Introduction

TencentLog

腾讯云结构化日志写入

引用

	allprojects {
		repositories {
			//...
			maven { url 'https://www.jitpack.io' }
		}
	}
	dependencies {
	        implementation 'com.github.dqh147258:TencentLog:1.0.7'
	}

使用

    companion object {
        private const val TENCENT_CLOUD_LOG_SECRET_ID = "your secret id"
        private const val TENCENT_CLOUD_LOG_SECRET_KEY = "your secret key"
        private const val TENCENT_CLOUD_LOG_AREA = "the area id of your tencent log server"
        private const val TENCENT_CLOUD_LOG_TOPIC_ID = "your topic id"
    }
    TencentLogManager.init(TENCENT_CLOUD_LOG_SECRET_ID, TENCENT_CLOUD_LOG_SECRET_KEY, TENCENT_CLOUD_LOG_AREA)
    val logWriter = TencentLogManager.instance.getLogWriter(TENCENT_CLOUD_LOG_TOPIC_ID)
    val map = HashMap<String, String>()
    map["test"] = "just for test"
    logWriter.log(map) { result, message ->
        if (!result) {
            Log.w(TAG, "report log to tencent cloud failed, message: $message")
        }
    }

注意

这里使用的protobuf库是protobuf-javalite

如果你使用的其它库(protobuf-java,protobuf-lite)则需要将其它的库排除掉,不然编译将会报错. 以protobuf-lite为例,在app的build.gradle中添加如下配置

android {
        //...
        configurations {
            implementation.exclude module:'protobuf-lite'
        }
}

如果项目中有使用到protobuf-java,请使用

	dependencies {
	        implementation 'com.github.dqh147258:TencentLog:2.0.+'
	}

源码是protobuf-java分支

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.