2021-02-19 08:28:05 -07:00
|
|
|
//
|
|
|
|
// ReactLogger.swift
|
2021-06-21 14:42:46 -06:00
|
|
|
// mrousavy
|
2021-02-19 08:28:05 -07:00
|
|
|
//
|
|
|
|
// Created by Marc Rousavy on 15.12.20.
|
2021-06-01 05:07:57 -06:00
|
|
|
// Copyright © 2020 mrousavy. All rights reserved.
|
2021-02-19 08:28:05 -07:00
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2021-03-09 02:53:29 -07:00
|
|
|
// MARK: - ReactLogger
|
|
|
|
|
2021-02-19 08:28:05 -07:00
|
|
|
enum ReactLogger {
|
2021-06-03 06:16:02 -06:00
|
|
|
/**
|
|
|
|
A function that logs to the JavaScript console.
|
|
|
|
*/
|
|
|
|
static var ConsoleLogFunction: ConsoleLogFunction?
|
|
|
|
|
|
|
|
/**
|
|
|
|
Log a message to the console in the format of `VisionCamera.[caller-function-name]: [message]`
|
|
|
|
|
|
|
|
@discussion
|
|
|
|
If the global ConsoleLogFunction is set, this function also logs to the JavaScript console (console.log, console.trace, console.warn or console.error)
|
|
|
|
This function also always logs to [RCTDefaultLogFunction].
|
|
|
|
In non-DEBUG builds, this function is no-op.
|
|
|
|
*/
|
|
|
|
@inlinable
|
2021-03-19 08:53:19 -06:00
|
|
|
static func log(level: RCTLogLevel,
|
|
|
|
message: String,
|
2021-06-03 06:16:02 -06:00
|
|
|
alsoLogToJS: Bool = false,
|
2021-03-19 08:53:19 -06:00
|
|
|
_ file: String = #file,
|
|
|
|
_ lineNumber: Int = #line,
|
|
|
|
_ function: String = #function) {
|
2021-06-03 06:16:02 -06:00
|
|
|
#if DEBUG
|
|
|
|
if alsoLogToJS, let log = ConsoleLogFunction {
|
|
|
|
log(level, "[native] VisionCamera.\(function): \(message)")
|
|
|
|
}
|
|
|
|
RCTDefaultLogFunction(level, RCTLogSource.native, file, lineNumber as NSNumber, "VisionCamera.\(function): \(message)")
|
|
|
|
#endif
|
2021-02-19 08:28:05 -07:00
|
|
|
}
|
|
|
|
}
|