Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.7.2
- Enhance logging methods in `PlayxCore` to use the new `PlayxLogger` system.

## 0.7.1

- Updated dependencies.
Expand Down
1 change: 1 addition & 0 deletions example/ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Runner/GeneratedPluginRegistrant.*
!default.mode2v3
!default.pbxuser
!default.perspectivev3
/Podfile.lock
16 changes: 8 additions & 8 deletions lib/src/logger/base_logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ abstract class PlayxBaseLogger {
void log(dynamic message, {String? tag});

/// Alias for [debug]
void d(dynamic message, {String? tag}) => debug;
void d(dynamic message, {String? tag}) => debug(message, tag: tag);

/// Alias for [info]
void i(dynamic message, {String? tag}) => info;
void i(dynamic message, {String? tag}) => info(message, tag: tag);

/// Alias for [warning]
void w(dynamic message, {String? tag}) => warning;
void w(dynamic message, {String? tag}) => warning(message, tag: tag);

/// Alias for [error]
void e(dynamic message,
{Object? error, StackTrace? stackTrace, String? tag}) =>
error;
{Object? error, StackTrace? stackTrace, String? tag}) => this.error(message,
error: error, stackTrace: stackTrace, tag: tag);

/// Alias for [critical]
void c(dynamic message, {String? tag}) => critical;
void c(dynamic message, {String? tag}) => critical(message, tag: tag);

/// Alias for [good]
void v(dynamic message, {String? tag}) => verbose;
void v(dynamic message, {String? tag}) => verbose(message, tag: tag);

/// Alias for [log]
void l(dynamic message, {String? tag}) => log;
void l(dynamic message, {String? tag}) => log(message, tag: tag);
}
18 changes: 17 additions & 1 deletion lib/src/logger/playx_logger.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import 'package:talker_flutter/talker_flutter.dart';

import 'talker_playx_logger.dart';
import 'playx_logger_settings.dart';
import 'base_logger.dart';
class DefaultColoredLoggerFormatter implements LoggerFormatter {
@override
String fmt(LogDetails details, TalkerLoggerSettings settings) {
final msg = details.message?.toString() ?? '';
final coloredMsg =
msg.split('\n').map((e) => details.pen.write(e)).toList().join('\n');
return coloredMsg;
}
}

/// A centralized static logger utility for Playx-based applications.
///
Expand Down Expand Up @@ -40,9 +51,12 @@ class PlayxLogger {
String? name,
PlayxLoggerSettings? settings,
bool setAsDefault = true,
bool useColoredFormatter = false,
}) {
final logger = TalkerPlayxLogger(
settings: settings ?? PlayxLoggerSettings(), name: name);
settings: settings ?? PlayxLoggerSettings(
formatter: useColoredFormatter? DefaultColoredLoggerFormatter() : ExtendedLoggerFormatter(),
), name: name);
name ??= 'PLAYX LOGGER';
_loggers[name] = logger;

Expand All @@ -51,6 +65,8 @@ class PlayxLogger {
}
}



/// Retrieves a logger instance by its [name].
///
/// Returns `null` if no logger exists with the given name.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/logger/playx_logger_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PlayxLoggerSettings {
this.printDateTime = false,
this.level = LogLevel.verbose,
this.lineSymbol = '─',
this.maxLineWidth = 110,
this.maxLineWidth = 120,
this.formatter = const ExtendedLoggerFormatter(),
this.output,
this.filter,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/playx_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ abstract class PlayxCore {
PlayxPrefsSettings prefsSettings = const PlayxPrefsSettings(),
WorkManagerSettings workerManagerSettings = const WorkManagerSettings(),
}) async {
PlayxLogger.initLogger(name: 'PLAYX CORE');
logger.debug('Booting Preferences...');
PlayxLogger.initLogger(name: 'PLAYX CORE', useColoredFormatter: true);
logger.i('Booting Preferences...');
if (prefsSettings.createPlayxPrefs) {
await PlayxPrefs.create();
}
Expand All @@ -120,7 +120,7 @@ abstract class PlayxCore {
await PlayxSecurePrefs.create(securePrefsSettings: securePrefsSettings);
}

logger.d('Booting Environment...');
logger.i('Booting Environment...');
if (envSettings != null) {
await PlayxEnv.load(
fileName: envSettings.fileName,
Expand All @@ -138,7 +138,7 @@ abstract class PlayxCore {
}

_getIt = GetIt.instance;
logger.debug('PlayxCore initialized');
logger.i('PlayxCore initialized');
}

/// Disposes the resources used by `playx_core`.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: playx_core
description: Core package for playx eco system contains shared classes and utilities.
version: 0.7.1
version: 0.7.2
homepage: https://sourcya.io/
repository: https://github.com/playx-flutter/playx_core
issue_tracker: https://github.com/playx-flutter/playx_core/issues
Expand Down
Loading