Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setcustomlogger implementation on iOS #1026

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

jsligh
Copy link
Collaborator

@jsligh jsligh commented Jul 16, 2024

Fixes #1023

@jsligh
Copy link
Collaborator Author

jsligh commented Jul 16, 2024

I will be making a docs PR after this is merged

@@ -33,38 +33,70 @@ public class Log: NSObject {
public static var logToFile = false

public static func error(_ object: Any, filename: String = #file, line: Int = #line, function: String = #function) {
log(object, logLevel: .error, filename: filename, line: line, function: function)
if (customLogger == nil) {
Copy link
Contributor

@YuriyVelichkoPI YuriyVelichkoPI Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, this kind of functionality should be implemented in the following way:

  1. Introduce the class SDKConsoleLogger which implements PrebidLogger protocol
  2. Introduce internal property var logger: PrebidLogger? = SDKConsoleLogger()
  3. Introduce a custom setter for the logger so pubs can set up own one.
  4. in all functions of the Log class just use logger?.dosomething( .... )

It will alow to avoid if ... else and seamlessly add another SDK loggers like SDKFileLogger if needed.

public static var logLevel: LogLevel = .debug
public static var logToFile = false

public static func error(_ object: Any, filename: String = #file, line: Int = #line, function: String = #function) {
log(object, logLevel: .error, filename: filename, line: line, function: function)
logger?.error(object, filename: filename, line: line, function: function)
}

public static func info(_ object: Any, filename: String = #file, line: Int = #line, function: String = #function) {
log(object, logLevel: .info, filename: filename, line: line, function: function)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, you should remove system fogging from the Log class. Otherwise, the same messages will be logged twice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They shouldn't because the SDKConsoleLogger's log method doesn't post to the system log.

@jsligh jsligh force-pushed the 1023-setcustomlogger-implementation-from-android-library-is-not-present-in-ios-library branch from 729d976 to bb768f8 Compare August 22, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setCustomLogger implementation from Android Library is not present in iOS library
2 participants