Skip to content

Commit

Permalink
add file logger (#6618)
Browse files Browse the repository at this point in the history
  • Loading branch information
enahum authored Sep 6, 2022
1 parent 9fd8781 commit a819bfc
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
8 changes: 4 additions & 4 deletions app/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
5 changes: 0 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}],
Expand Down
8 changes: 8 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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]`',
Expand Down
12 changes: 12 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -654,6 +661,7 @@ SPEC REPOS:
trunk:
- Alamofire
- CocoaAsyncSocket
- CocoaLumberjack
- Flipper
- Flipper-Boost-iOSX
- Flipper-DoubleConversion
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -854,6 +864,7 @@ SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
BVLinearGradient: 34a999fda29036898a09c6a6b728b0b4189e1a44
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
CocoaLumberjack: 543c79c114dadc3b1aba95641d8738b06b05b646
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 1d83d91816fa605d16227a83f1b2e71c8df09d22
FBReactNativeSpec: 626e35e73f83c637ff166f906d584f4c6750c251
Expand All @@ -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
Expand Down
29 changes: 16 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit a819bfc

Please sign in to comment.