Skip to content

Commit 762917b

Browse files
Syncing changes from private repository
1 parent 0a1a053 commit 762917b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+676
-124
lines changed

.github/pull_request_template.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

Android~/src/logging/LogLevel.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@file:Suppress("PackageDirectoryMismatch")
2+
package com.chartboost.mediation.unity.logging
3+
4+
enum class LogLevel(var value: Int) {
5+
DISABLED(0),
6+
ERROR(1),
7+
WARNING(2),
8+
INFO(3),
9+
DEBUG(4),
10+
VERBOSE(5);
11+
12+
companion object {
13+
/**
14+
* Get the log level corresponding to the integer value or VERBOSE if nothing matches.
15+
*
16+
* @param logLevelInt Integer representation of the log level.
17+
*/
18+
fun fromInt(logLevelInt: Int?): LogLevel = entries.find { it.value == logLevelInt } ?: VERBOSE
19+
}
20+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@file:Suppress("PackageDirectoryMismatch")
2+
package com.chartboost.mediation.unity.logging
3+
4+
import android.util.Log
5+
6+
class UnityLoggingBridge {
7+
8+
companion object {
9+
10+
private var loggingObserver: UnityLoggingObserver? = null
11+
private var logLevel: LogLevel = LogLevel.INFO
12+
13+
@Suppress("unused")
14+
15+
@JvmStatic
16+
fun setUnityLoggingObserver(loggingObserver: UnityLoggingObserver) {
17+
this.loggingObserver = loggingObserver
18+
}
19+
20+
@Suppress("unused")
21+
@JvmStatic
22+
fun setLogLevel(logLevel: Int){
23+
this.logLevel = LogLevel.fromInt(logLevel)
24+
}
25+
26+
@Suppress("unused")
27+
@JvmStatic
28+
fun getLogLevel(): Int {
29+
return logLevel.value
30+
}
31+
32+
fun log(tag: String?, message: String, logLevel: LogLevel){
33+
if (this.logLevel == LogLevel.DISABLED)
34+
return
35+
36+
if (logLevel > this.logLevel) {
37+
return
38+
}
39+
40+
when (logLevel) {
41+
LogLevel.WARNING -> Log.w(tag, message)
42+
LogLevel.DEBUG -> Log.d(tag, message)
43+
LogLevel.INFO -> Log.i(tag, message)
44+
LogLevel.VERBOSE -> Log.v(tag, message)
45+
LogLevel.ERROR -> Log.e(tag, message)
46+
LogLevel.DISABLED -> return
47+
}
48+
49+
loggingObserver?.onBridgeLog("$tag $message", logLevel.value)
50+
}
51+
52+
fun logException(tag: String?, exception: String){
53+
Log.e(tag, exception)
54+
loggingObserver?.onBridgeException("$tag $exception")
55+
}
56+
}
57+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@file:Suppress("PackageDirectoryMismatch")
2+
package com.chartboost.mediation.unity.logging
3+
4+
interface UnityLoggingObserver {
5+
fun onBridgeLog(logMessage: String, logLevel:Int)
6+
7+
fun onBridgeException(exception: String)
8+
}

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22
All notable changes to this project will be documented in this file using the standards as defined at [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0).
33

4-
### Version 1.0.0 *(2024-08-01)*
4+
### Version 1.1.0 *(2024-09-19)*
5+
Added:
6+
- Support to native wrapper logs through `UnityLoggingBridge`.
7+
- `WrapperMessageLogged` event listener in `LogController` class. Use to listen for any log events communicated between Unity and native layers.
58

9+
### Version 1.0.0 *(2024-08-01)*
610
First version of Chartboost Logging Utilities package for Unity.
711

812
Added:
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<package>
3-
<metadata>
4-
<id>Chartboost.CSharp.Logging.Unity</id>
5-
<version>1.0.0</version>
6-
<title>Chartboost Logging for Unity</title>
7-
<description>Reusable Centralized Logging for Chartboost's Unity Projects</description>
8-
<authors>Chartboost</authors>
9-
<owners>Chartboost</owners>
10-
<license type="file">LICENSE.md</license>
11-
<readme>README.md</readme>
12-
<copyright>Copyright 2024</copyright>
13-
<tags>Chartboost, Ads, Mediation, Unity, cs</tags>
14-
<repository type="git" url="https://github.com/ChartBoost/chartboost-unity-logging"/>
15-
</metadata>
16-
</package>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package>
3+
<metadata>
4+
<id>Chartboost.CSharp.Logging.Unity</id>
5+
<version>1.1.0</version>
6+
<title>Chartboost Logging for Unity</title>
7+
<description>Reusable Centralized Logging for Chartboost's Unity Projects</description>
8+
<authors>Chartboost</authors>
9+
<owners>Chartboost</owners>
10+
<license type="file">LICENSE.md</license>
11+
<readme>README.md</readme>
12+
<copyright>Copyright 2024</copyright>
13+
<tags>Chartboost, Ads, Mediation, Unity, cs</tags>
14+
<repository type="git" url="https://github.com/ChartBoost/chartboost-unity-logging"/>
15+
<dependencies>
16+
<dependency id="Chartboost.CSharp.Threading.Unity" version="1.0.2" />
17+
<dependency id="Chartboost.CSharp.Utilities.Unity" version="1.0.2" />
18+
</dependencies>
19+
</metadata>
20+
</package>

Runtime/Android.meta

Lines changed: 2 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Android/AndroidExtensions.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

Runtime/Android/AssemblyInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using UnityEngine.Scripting;
2+
3+
[assembly: AlwaysLinkAssembly]

Runtime/Android/AssemblyInfo.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)