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
7 changes: 7 additions & 0 deletions examples/counter_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,13 @@ packages:
relative: true
source: path
version: "0.3.0"
stac_logger:
dependency: "direct overridden"
description:
path: "../../packages/stac_logger"
relative: true
source: path
version: "1.0.0"
stack_trace:
dependency: transitive
description:
Expand Down
4 changes: 3 additions & 1 deletion examples/counter_example/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# melos_managed_dependency_overrides: stac,stac_framework
# melos_managed_dependency_overrides: stac,stac_framework,stac_logger
dependency_overrides:
stac:
path: ../../packages/stac
stac_framework:
path: ../../packages/stac_framework
stac_logger:
path: ../../packages/stac_logger
7 changes: 7 additions & 0 deletions examples/movie_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,13 @@ packages:
relative: true
source: path
version: "0.3.0"
stac_logger:
dependency: "direct overridden"
description:
path: "../../packages/stac_logger"
relative: true
source: path
version: "1.0.0"
stack_trace:
dependency: transitive
description:
Expand Down
4 changes: 3 additions & 1 deletion examples/movie_app/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# melos_managed_dependency_overrides: stac,stac_framework
# melos_managed_dependency_overrides: stac,stac_framework,stac_logger
dependency_overrides:
stac:
path: ../../packages/stac
stac_framework:
path: ../../packages/stac_framework
stac_logger:
path: ../../packages/stac_logger
7 changes: 7 additions & 0 deletions examples/stac_gallery/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,13 @@ packages:
relative: true
source: path
version: "0.3.0"
stac_logger:
dependency: "direct overridden"
description:
path: "../../packages/stac_logger"
relative: true
source: path
version: "1.0.0"
stac_webview:
dependency: "direct main"
description:
Expand Down
4 changes: 3 additions & 1 deletion examples/stac_gallery/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# melos_managed_dependency_overrides: stac,stac_framework,stac_webview
# melos_managed_dependency_overrides: stac,stac_framework,stac_webview,stac_logger
dependency_overrides:
stac:
path: ../../packages/stac
stac_framework:
path: ../../packages/stac_framework
stac_logger:
path: ../../packages/stac_logger
stac_webview:
path: ../../packages/stac_webview
2 changes: 1 addition & 1 deletion packages/stac/lib/src/framework/stac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import 'package:stac/src/parsers/parsers.dart';
import 'package:stac/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart';
import 'package:stac/src/parsers/widgets/stac_set_value/stac_set_value_parser.dart';
import 'package:stac/src/services/stac_network_service.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac/src/utils/variable_resolver.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_logger/stac_logger.dart';

typedef ErrorWidgetBuilder = Widget Function(
BuildContext context,
Expand Down
2 changes: 1 addition & 1 deletion packages/stac/lib/src/framework/stac_registry.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:stac/src/utils/log.dart';
import 'package:stac_logger/stac_logger.dart';
import 'package:stac_framework/stac_framework.dart';

class StacRegistry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import 'dart:async';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:stac/src/parsers/actions/stac_network_request/stac_network_request.dart';
import 'package:stac/src/framework/framework.dart';
import 'package:stac/src/parsers/actions/stac_network_request/stac_network_request.dart';
import 'package:stac/src/services/stac_network_service.dart';
import 'package:stac/src/utils/action_type.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_logger/stac_logger.dart';

class StacNetworkRequestParser extends StacActionParser<StacNetworkRequest> {
const StacNetworkRequestParser();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:stac/src/framework/framework.dart';
import 'package:stac/src/parsers/widgets/stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_logger/stac_logger.dart';

class StacDefaultBottomNavigationControllerParser
extends StacParser<StacDefaultBottomNavigationController> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:flutter/material.dart';
import 'package:stac/src/framework/framework.dart';
import 'package:stac/src/parsers/widgets/stac_dynamic_view/stac_dynamic_view.dart';
import 'package:stac/src/services/stac_network_service.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_logger/stac_logger.dart';

class StacDynamicViewParser extends StacParser<StacDynamicView> {
const StacDynamicViewParser();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac_logger/stac_logger.dart';

class StacFormScope extends InheritedWidget {
const StacFormScope({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:flutter/cupertino.dart';
import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart';
import 'package:stac/src/utils/color_utils.dart';
import 'package:stac/src/utils/icon_utils.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_logger/stac_logger.dart';

import 'stac_icon.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac_logger/stac_logger.dart';

class StacRadioGroupScope extends InheritedWidget {
const StacRadioGroupScope({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'package:stac/src/parsers/parsers.dart';
import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart';
import 'package:stac/src/utils/color_utils.dart';
import 'package:stac/src/utils/input_validations.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_logger/stac_logger.dart';

class StacTextFormFieldParser extends StacParser<StacTextFormField> {
const StacTextFormFieldParser();
Expand Down
2 changes: 1 addition & 1 deletion packages/stac/lib/src/utils/input_formatters.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/services.dart';
import 'package:stac/src/utils/log.dart';
import 'package:stac_logger/stac_logger.dart';

enum InputFormatterType {
allow,
Expand Down
12 changes: 0 additions & 12 deletions packages/stac/lib/src/utils/log.dart

This file was deleted.

1 change: 1 addition & 0 deletions packages/stac/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
stac_framework: ^0.3.0
cached_network_image: ^3.4.1
flutter_svg: ^2.1.0
stac_logger: ^1.0.0

dev_dependencies:
flutter_test:
Expand Down
4 changes: 3 additions & 1 deletion packages/stac/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# melos_managed_dependency_overrides: stac_framework
# melos_managed_dependency_overrides: stac_framework,stac_logger
dependency_overrides:
stac_framework:
path: ../stac_framework
stac_logger:
path: ../stac_logger
31 changes: 31 additions & 0 deletions packages/stac_logger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
build/
10 changes: 10 additions & 0 deletions packages/stac_logger/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "b25305a8832cfc6ba632a7f87ad455e319dccce8"
channel: "stable"

project_type: package
3 changes: 3 additions & 0 deletions packages/stac_logger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

* Initial release of the stac_logger package
21 changes: 21 additions & 0 deletions packages/stac_logger/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Stac

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions packages/stac_logger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Stac Logger

A lightweight and reusable logging utility for the Stac framework. It switches between implementations—using Flutter's debugPrint on web/WASM platforms and the robust logger package on native platforms—ensuring optimal performance and compatibility across all environments.

## Getting started

Add the package to your `pubspec.yaml`:

```yaml
dependencies:
stac_logger: ^1.0.0
```

Then run:

```bash
flutter pub get
```

## Usage

Import the package and use the `Log` class to log messages:

```dart
import 'package:stac_logger/stac_logger.dart';

void main() {
// Log a debug message
Log.d('Debug message');

// Log an info message
Log.i('Info message');

// Log a warning message
Log.w('Warning message');

// Log an error message
Log.e('Error message');
}
```

## Implementation Details

This package uses conditional imports to select the appropriate logging implementation based on the platform:

- On native platforms (iOS, Android, desktop), it uses a full-featured logger implementation
- On web/WASM platforms, it uses a simplified implementation compatible with those environments

The conditional import approach ensures that no `dart:io` code is included in web/WASM builds, making the package fully compatible with WebAssembly.

## Additional information

This package is part of the Stac framework ecosystem and is designed to provide logging functionality that works across all platforms, including WASM environments
4 changes: 4 additions & 0 deletions packages/stac_logger/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
24 changes: 24 additions & 0 deletions packages/stac_logger/lib/src/log.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:stac_logger/src/log_interface.dart';

import 'log_io.dart' // Default implementation for non-web platforms
if (dart.library.html) 'log_web.dart'; // Web/WASM implementation

class Log {
const Log._();

// Get the logger instance directly from the conditionally imported file
// The compiler will select the appropriate implementation at compile time
static final LogInterface _logger = createLogger();

/// Logs a debug message
static void d(dynamic message) => _logger.d(message);

/// Logs an info message
static void i(dynamic message) => _logger.i(message);

/// Logs a warning message
static void w(dynamic message) => _logger.w(message);

/// Logs an error message
static void e(dynamic message) => _logger.e(message);
}
14 changes: 14 additions & 0 deletions packages/stac_logger/lib/src/log_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// Abstract interface for logging functionality
abstract class LogInterface {
/// Log a debug message
void d(dynamic message);

/// Log an info message
void i(dynamic message);

/// Log a warning message
void w(dynamic message);

/// Log an error message
void e(dynamic message);
}
26 changes: 26 additions & 0 deletions packages/stac_logger/lib/src/log_io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:logger/logger.dart';
import 'log_interface.dart';

LogInterface createLogger() => LogIO.instance;

/// IO-based implementation of LogInterface
class LogIO implements LogInterface {
LogIO._();

static final LogIO _instance = LogIO._();
static LogIO get instance => _instance;

final _log = Logger();

@override
void d(dynamic message) => _log.d(message);

@override
void i(dynamic message) => _log.i(message);

@override
void w(dynamic message) => _log.w(message);

@override
void e(dynamic message) => _log.e(message);
}
Loading