Application Library
- As pictured below, using application libraries enables to transfer of logs to the Hive log collect server.
Examples
For more samples of other languages, go to Hive Console > Analytics > Log Definition. Details
java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
// https://github.com/fluent/fluent-logger-java package com.hive.sample; import java.util.Date; import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Map; import org.fluentd.logger.FluentLogger; public class GameLogAPI { private static FluentLogger LOG = FluentLogger.getLogger("ha2union.gameserver.java"); public static void log_hive_login_log(String ageGate13, String changeUid, String thirdPartyAssent, String tag1, String hiveNewUser, String timezone, String channel, String source, String serverId, String osVer, long vid, long uid, String appId, String company, String model, String lang, String class, String os, String appVer, String cpu, String market, String clientIp, String sdkVer, String serverIp, long did, String grouping, String newUser, String guestUser, String lastLoginDate, String hiveSnsType, String userId, String deviceName, String osVersionFixed, String serverUid, long level, long isEmulator) { java.util.Map<String, Object> logData = new java.util.HashMap<String, Object>(); logData.put("changeUid", changeUid); logData.put("thirdPartyAssent", thirdPartyAssent); logData.put("tag1", tag1); logData.put("hiveNewUser", hiveNewUser); logData.put("dateTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // The log's current time (in Korean time) logData.put("timezone", timezone); logData.put("channel", "C2S"); logData.put("source", source); logData.put("serverId", serverId); logData.put("osVer", osVer); logData.put("vid", vid); logData.put("uid", uid); logData.put("appId", "com.gcp2.hivesdk.android.google.global.normal"); logData.put("wasRegistTimestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // Server time logData.put("company", company); logData.put("model", model); logData.put("lang", lang); logData.put("class", class); logData.put("os", os); logData.put("appVer", appVer); logData.put("cpu", cpu); logData.put("market", market); logData.put("clientIp", clientIp); logData.put("guid", java.util.UUID.randomUUID().toString()); logData.put("sdkVer", sdkVer); logData.put("serverIp", serverIp); logData.put("category", "hive_test_login_log"); logData.put("did", did); logData.put("grouping", grouping); logData.put("newUser", newUser); logData.put("guestUser", guestUser); logData.put("lastLoginDate", lastLoginDate); logData.put("hiveSnsType", hiveSnsType); logData.put("userId", userId); logData.put("deviceName", deviceName); logData.put("osVersionFixed", osVersionFixed); logData.put("serverUid", serverUid); logData.put("level", level); logData.put("isEmulator", isEmulator); LOG.log("hive_login_log", logData); } |
python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# coding=utf-8 # pip install fluent-logger from fluent import sender import datetime import uuid def send_hive_login_log(): data = { "ageGate13" : "Y", "changeUid" : "90010023021", "thirdPartyAssent" : "C", "tag1" : "sample valuyes", "hiveNewUser" : "Y", "dateTime" : datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S"), "timezone" : "GMT+09:00", "channel" : "C2S", "source" : "Web", "serverId" : "1", "osVer" : "4.3.1", "vid" : "22222222", "uid" : "11111111", "appId" : "com.gcp2.hivesdk.android.google.global.normal", "wasRegistTimestamp" : datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S"), "company" : "C2S", "model" : "SHW-M250S", "lang" : "ko", "class" : "sample value of class", "os" : "A", "appVer" : "1.0", "cpu" : "armeabi-v7a", "market" : "GO", "clientIp" : "127.0.0.1", "guid" : str(uuid.uuid4()), "sdkVer" : "2.0.1", "serverIp" : "127.0.0.2", "category" : "hive_test_login_log", "did" : "33333333", "grouping" : "com.com2us.xxx", "newUser" : "N", "guestUser" : "N", "lastLoginDate" : "2017-02-28 14:33:00", "hiveSnsType" : "FB", "userId" : "123456789", "deviceName" : "SM-G935", "osVersionFixed" : "9.2.1", "serverUid" : "QA-2", "level" : "7", "isEmulator" : "1" } logger = sender.FluentSender("ha2union.gameserver.python", host='localhost', port=24224, timeout=10.0) ret = logger.emit("hive_login_log", data) return ret |
php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
<?php // Required installing fluented to server in advance require_once __DIR__.'/vendor/autoload.php'; use Fluent\Logger\FluentLogger; function sink_log_hive_login_log() { $data = array( "ageGate13" => "Y", "changeUid" => "90010023021", "thirdPartyAssent" => "C", "tag1" => "sample valuyes", "hiveNewUser" => "Y", "dateTime" => gmdate("Y-m-d H:i:s", time()), "timezone" => "GMT", "channel" => "C2S", "source" => "Web", "serverId" => "1", "osVer" => "4.3.1", "vid" => "22222222", "uid" => "11111111", "appId" => "com.gcp2.hivesdk.android.google.global.normal", "wasRegistTimestamp" => gmdate("Y-m-d H:i:s", time()), "company" => "C2S", "model" => "SHW-M250S", "lang" => "ko", "class" => "sample value of class", "os" => "A", "appVer" => "1.0", "cpu" => "armeabi-v7a", "market" => "GO", "clientIp" => "127.0.0.1", "guid" => md5(uniqid(rand(), true)), "sdkVer" => "2.0.1", "serverIp" => "127.0.0.2", "category" => "hive_test_login_log", "did" => "33333333", "grouping" => "com.com2us.xxx", "newUser" => "N", "guestUser" => "N", "lastLoginDate" => "2017-02-28 14:33:00", "hiveSnsType" => "FB", "userId" => "123456789", "deviceName" => "SM-G935", "osVersionFixed" => "9.2.1", "serverUid" => "QA-2", "level" => "7", "isEmulator" => "1" ); $logger = new FluentLogger("unix:///dev/shm/fluentd.sock"); $result = $logger->post("ha2union.hive.hive_login_log", $data); if ($result === false){ // Executes in deactivating the td-agent in local // Saved in a temporary folder for each server } return $result; } |