diff --git a/app/utils/log.ts b/app/utils/log.ts index bbdbbc4ccb..fb325a6854 100644 --- a/app/utils/log.ts +++ b/app/utils/log.ts @@ -3,20 +3,20 @@ export function logError(...args: any[]) { // eslint-disable-next-line no-console - console.error('Error:', ...args); + console.error(...args); } export function logWarning(...args: any[]) { // eslint-disable-next-line no-console - console.warn('Warning:', ...args); + console.warn(...args); } export function logInfo(...args: any[]) { // eslint-disable-next-line no-console - console.log('Info:', ...args); + console.log(...args); } export function logDebug(...args: any[]) { // eslint-disable-next-line no-console - console.debug('Debug:', ...args); + console.debug(...args); } diff --git a/babel.config.js b/babel.config.js index d40bbed902..2cd4cb21dd 100644 --- a/babel.config.js +++ b/babel.config.js @@ -6,11 +6,6 @@ module.exports = { '@babel/preset-typescript', ['@babel/preset-env', {targets: {node: 'current'}}], ], - env: { - production: { - plugins: ['transform-remove-console'], - }, - }, plugins: [ '@babel/plugin-transform-runtime', ['@babel/plugin-proposal-decorators', {legacy: true}], diff --git a/index.ts b/index.ts index 0f0bc4550b..6c07e55739 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import TurboLogger from '@mattermost/react-native-turbo-log'; import {DeviceEventEmitter, LogBox} from 'react-native'; import {RUNNING_E2E} from 'react-native-dotenv'; import 'react-native-gesture-handler'; @@ -22,6 +23,13 @@ import {logInfo} from './app/utils/log'; declare const global: { HermesInternal: null | {} }; +TurboLogger.configure({ + dailyRolling: false, + logToFile: !__DEV__, + maximumFileSize: 1024 * 1024, + maximumNumberOfFiles: 2, +}); + if (__DEV__) { LogBox.ignoreLogs([ '`-[RCTRootView cancelTouches]`', diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1ee4e488e1..9df6f08f62 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -4,6 +4,9 @@ PODS: - BVLinearGradient (2.6.2): - React-Core - CocoaAsyncSocket (7.6.5) + - CocoaLumberjack (3.7.4): + - CocoaLumberjack/Core (= 3.7.4) + - CocoaLumberjack/Core (3.7.4) - DoubleConversion (1.1.6) - FBLazyVector (0.69.3) - FBReactNativeSpec (0.69.3): @@ -90,6 +93,9 @@ PODS: - libwebp/mux (1.2.1): - libwebp/demux - libwebp/webp (1.2.1) + - mattermost-react-native-turbo-log (0.2.0): + - CocoaLumberjack + - React-Core - OpenSSL-Universal (1.1.1100) - Permission-Camera (3.6.0): - RNPermissions @@ -572,6 +578,7 @@ DEPENDENCIES: - hermes-engine (from `../node_modules/react-native/sdks/hermes/hermes-engine.podspec`) - jail-monkey (from `../node_modules/jail-monkey`) - libevent (~> 2.1.12) + - "mattermost-react-native-turbo-log (from `../node_modules/@mattermost/react-native-turbo-log`)" - OpenSSL-Universal (= 1.1.1100) - Permission-Camera (from `../node_modules/react-native-permissions/ios/Camera`) - Permission-Microphone (from `../node_modules/react-native-permissions/ios/Microphone`) @@ -654,6 +661,7 @@ SPEC REPOS: trunk: - Alamofire - CocoaAsyncSocket + - CocoaLumberjack - Flipper - Flipper-Boost-iOSX - Flipper-DoubleConversion @@ -694,6 +702,8 @@ EXTERNAL SOURCES: :podspec: "../node_modules/react-native/sdks/hermes/hermes-engine.podspec" jail-monkey: :path: "../node_modules/jail-monkey" + mattermost-react-native-turbo-log: + :path: "../node_modules/@mattermost/react-native-turbo-log" Permission-Camera: :path: "../node_modules/react-native-permissions/ios/Camera" Permission-Microphone: @@ -854,6 +864,7 @@ SPEC CHECKSUMS: boost: a7c83b31436843459a1961bfd74b96033dc77234 BVLinearGradient: 34a999fda29036898a09c6a6b728b0b4189e1a44 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 + CocoaLumberjack: 543c79c114dadc3b1aba95641d8738b06b05b646 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: 1d83d91816fa605d16227a83f1b2e71c8df09d22 FBReactNativeSpec: 626e35e73f83c637ff166f906d584f4c6750c251 @@ -873,6 +884,7 @@ SPEC CHECKSUMS: jail-monkey: de7eab0c9cbe4e7cdd2f80d04f812337ae94b2e0 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 libwebp: 98a37e597e40bfdb4c911fc98f2c53d0b12d05fc + mattermost-react-native-turbo-log: 5c269c7c27d7f1db3d03300cf50d659d0d269126 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c Permission-Camera: 0a0fb4341f50ab242f496fb2f73380e0ec454fe7 Permission-Microphone: 84bf2faad8d87969e8e275e9917a174424f948fc diff --git a/package-lock.json b/package-lock.json index 96e8574e86..4d72a06226 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@mattermost/react-native-emm": "1.3.0", "@mattermost/react-native-network-client": "1.0.0", "@mattermost/react-native-paste-input": "0.5.0", + "@mattermost/react-native-turbo-log": "0.2.0", "@msgpack/msgpack": "2.7.2", "@nozbe/watermelondb": "0.24.0", "@nozbe/with-observables": "1.4.0", @@ -144,7 +145,6 @@ "babel-jest": "28.1.3", "babel-loader": "8.2.5", "babel-plugin-module-resolver": "4.1.0", - "babel-plugin-transform-remove-console": "6.9.4", "deep-freeze": "0.0.1", "detox": "19.9.0", "eslint": "8.21.0", @@ -3778,6 +3778,15 @@ "react-native": "*" } }, + "node_modules/@mattermost/react-native-turbo-log": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@mattermost/react-native-turbo-log/-/react-native-turbo-log-0.2.0.tgz", + "integrity": "sha512-w5SnCUnmxr3ynvaaxgMrrS3ZlkeNhR2BnPnSCQE1YInJvgju9B9VFWU37L83jfvuJN6r9+43sxImjNVLLAmlLA==", + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/@msgpack/msgpack": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-2.7.2.tgz", @@ -7746,12 +7755,6 @@ "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz", "integrity": "sha512-Xj9XuRuz3nTSbaTXWv3itLOcxyF4oPD8douBBmj7U9BBC6nEBYfyOJYQMf/8PJAFotC62UY5dFfIGEPr7WswzQ==" }, - "node_modules/babel-plugin-transform-remove-console": { - "version": "6.9.4", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-remove-console/-/babel-plugin-transform-remove-console-6.9.4.tgz", - "integrity": "sha1-uYA2DAZzhOJLNXpYjYB9PINSd4A=", - "dev": true - }, "node_modules/babel-preset-current-node-syntax": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", @@ -27954,6 +27957,12 @@ "deprecated-react-native-prop-types": "^2.3.0" } }, + "@mattermost/react-native-turbo-log": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@mattermost/react-native-turbo-log/-/react-native-turbo-log-0.2.0.tgz", + "integrity": "sha512-w5SnCUnmxr3ynvaaxgMrrS3ZlkeNhR2BnPnSCQE1YInJvgju9B9VFWU37L83jfvuJN6r9+43sxImjNVLLAmlLA==", + "requires": {} + }, "@msgpack/msgpack": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-2.7.2.tgz", @@ -30978,12 +30987,6 @@ "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz", "integrity": "sha512-Xj9XuRuz3nTSbaTXWv3itLOcxyF4oPD8douBBmj7U9BBC6nEBYfyOJYQMf/8PJAFotC62UY5dFfIGEPr7WswzQ==" }, - "babel-plugin-transform-remove-console": { - "version": "6.9.4", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-remove-console/-/babel-plugin-transform-remove-console-6.9.4.tgz", - "integrity": "sha1-uYA2DAZzhOJLNXpYjYB9PINSd4A=", - "dev": true - }, "babel-preset-current-node-syntax": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", diff --git a/package.json b/package.json index bc04975078..3e32f08e6c 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@mattermost/react-native-emm": "1.3.0", "@mattermost/react-native-network-client": "1.0.0", "@mattermost/react-native-paste-input": "0.5.0", + "@mattermost/react-native-turbo-log": "0.2.0", "@msgpack/msgpack": "2.7.2", "@nozbe/watermelondb": "0.24.0", "@nozbe/with-observables": "1.4.0", @@ -141,7 +142,6 @@ "babel-jest": "28.1.3", "babel-loader": "8.2.5", "babel-plugin-module-resolver": "4.1.0", - "babel-plugin-transform-remove-console": "6.9.4", "deep-freeze": "0.0.1", "detox": "19.9.0", "eslint": "8.21.0",