Native CocoaLumberjack Logging Framework for iOS.
Install React Native Lumberjack:
$ yarn add react-native-lumberjack
Then link it to your project:
$ react-native link
Once the project is linked, ensure that you add CocoaLumberjack
is integrated
into your project already. You can follow the Carthage
guide on their docs to add the framework.
Then, set up any loggers at the top of your AppDelegate()
file application:didFinishLaunchingWithOptions:
function:
[DDLog addLogger:[DDOSLogger sharedInstance]];
// (opt) log to the system hard drive (with default DDFileLogger log rolling behavior).
DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
[DDLog addLogger:fileLogger];
This lightweight project has a minimal impact on JS modules to utilize the
CocoaLumberjack
operations. This project exports a Log Builder which allows
modules to supply unique names, for convenience purposes.
const Log = require('react-native-lumberjack')('MyApp:ModuleName');
class MyService {
async performOperation() {
try {
// ...
Log.info('Response from operation')
// ...
} catch (err) {
Log.warn(err, "Unable to perform operation");
throw err;
}
}
}
You can run an example project for react-native-lumberjack
to see how this
project works by launching the examples/ios/RNLumberjack.xcodeproj
file.
In Xcode 10, you may see a build failure the first time you build. This is because
of React Native's lack of support for the new Xcode build
system. After the first build, Xcode will have ran the postinstall
script of
react-native
, which installs and configures the third-party
modules, and
therefore allows a successful Xcode build with the new build system.
- This module is currently in initial stages of development, and it not recommended for large-scale use