Skip to content

Commit

Permalink
Merge pull request #7 from fullstorydev/emerssso/MOCA-9778/update-log…
Browse files Browse the repository at this point in the history
…-levels

Adjust log levels to match session replay console.
  • Loading branch information
emerssso authored Jan 15, 2025
2 parents c75e632 + c8313cd commit 8bf20d3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ class FullstoryFlutterPlugin() : FlutterPlugin, MethodCallHandler {
val message = call.argument<String>("message")
val level = when (levelB) {
0 -> FS.LogLevel.LOG // A.K.A. Verbose
1 -> FS.LogLevel.DEBUG
2 -> FS.LogLevel.INFO
3 -> FS.LogLevel.WARN
4 -> FS.LogLevel.ERROR
5 -> FS.LogLevel.ERROR // Assert on iOS; not actually enabled at the moment because it's a reserved keyword in dart.
else -> FS.LogLevel.INFO // default. Alternatively we could error here.
1 -> FS.LogLevel.INFO
2 -> FS.LogLevel.WARN
3 -> FS.LogLevel.ERROR
else -> result.error("INVALID_ARGUMENTS", "Unexpected log level, expected value 0-3, got ${levelB}")
}
FS.log(level, message)
result.success(null)
Expand Down
12 changes: 5 additions & 7 deletions ios/Classes/FullstoryFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,17 @@ public class FullstoryFlutterPlugin: NSObject, FlutterPlugin, FSDelegate {
}
var levelValue: FSEventLogLevel;
switch level {
case 0, 1:
case 0:
levelValue = FSLOG_DEBUG
case 2:
case 1:
levelValue = FSLOG_INFO
case 3:
case 2:
levelValue = FSLOG_WARNING
case 4:
case 3:
levelValue = FSLOG_ERROR
case 5:
levelValue = FSLOG_ASSERT
default:
result(FlutterError(code: "INVALID_ARGUMENTS",
message: "Unexpected log level, expected value 0-5, got \(level)",
message: "Unexpected log level, expected value 0-3, got \(level)",
details: nil))
return
}
Expand Down
16 changes: 10 additions & 6 deletions lib/fs_log_level.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
/// Log levels. Controls how logs appear in the Dev tools > Console section of a Fullstory session replay
///
/// These correspond to the levels shown in session replay,
/// not the the levels used in Android/iOS logging.
enum FSLogLevel {
// Note: the order matters; the index is used to match to the appropriate value in the android and ios platform code

/// Verbose on Android, clamps to Debug on iOS
/// Lower than default level logging.
///
/// Equivalent to debug level on Android and iOS.
log,

/// Debug log level, currently combined with `log` in Fullstory's console.
debug,

/// Info log level, default
info,

/// Warn log level
warn,

/// Error log level. Will appear in in both the console and the event list in Fullstory
/// Error log level.
///
/// Will appear in in both the console and the event list in Fullstory
error,

//assert, // treated as error on iOS, not available on Android. Disabled here because it's a reserved keyword in dart.
// exception, Not currently supported by underlying platforms.
}

0 comments on commit 8bf20d3

Please sign in to comment.