2016-10-19 11:01:24 -07:00
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
namespace Facebook.Yoga
|
2016-10-19 11:01:24 -07:00
|
|
|
|
{
|
2016-12-02 11:18:16 -08:00
|
|
|
|
internal static class YogaLogger
|
2016-10-19 11:01:24 -07:00
|
|
|
|
{
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public delegate void Func(YogaLogLevel level, string message);
|
2016-10-19 11:01:24 -07:00
|
|
|
|
|
|
|
|
|
private static bool _initialized;
|
|
|
|
|
|
|
|
|
|
public static Func Logger = null;
|
|
|
|
|
|
|
|
|
|
public static void Initialize()
|
|
|
|
|
{
|
|
|
|
|
if (!_initialized)
|
|
|
|
|
{
|
2017-02-16 11:07:50 -08:00
|
|
|
|
|
|
|
|
|
Native.YGInteropSetLogger(LoggerInternal);
|
2016-10-19 11:01:24 -07:00
|
|
|
|
_initialized = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-16 11:07:50 -08:00
|
|
|
|
|
|
|
|
|
#if __IOS__
|
|
|
|
|
[ObjCRuntime.MonoPInvokeCallback(typeof(Func))]
|
|
|
|
|
#endif
|
|
|
|
|
public static void LoggerInternal(YogaLogLevel level, string message)
|
|
|
|
|
{
|
|
|
|
|
if (Logger != null)
|
|
|
|
|
{
|
|
|
|
|
Logger(level, message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (level == YogaLogLevel.Error)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 11:01:24 -07:00
|
|
|
|
}
|
|
|
|
|
}
|