Skip to content
Draft
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.7.0-wip

- **BREAKING:** Remove the `logger` field from `logger.dart` and made its
method functions.
- **BREAKING:** Remove the `logger` exports from
`package:firebase_functions/firebase_functions.dart`.

## 0.6.0

- Add `runFunctions` as the primary API.
Expand Down
2 changes: 1 addition & 1 deletion example/alerts/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/database/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/eventarc/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/firestore/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/firestore_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/https/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/pubsub/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/remoteconfig/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/scheduler/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/storage/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/tasks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 1 addition & 1 deletion example/testlab/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
sdk: ^3.7.0

dependencies:
firebase_functions: ^0.6.0-0
firebase_functions: ^0.7.0-0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
2 changes: 0 additions & 2 deletions lib/firebase_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export 'src/firestore/firestore.dart';
export 'src/https/https.dart';
// Experimental: Identity triggers (not yet supported in production or emulator)
export 'src/identity/identity.dart';
// Logger
export 'src/logger/logger.dart' show LogEntry, LogSeverity, Logger, logger;
// Experimental: Pub/Sub triggers (not yet supported in production or emulator)
export 'src/pubsub/pubsub.dart';
// Experimental: Remote Config triggers (not yet supported in production or emulator)
Expand Down
29 changes: 6 additions & 23 deletions lib/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,29 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Structured logger for Cloud Logging, compatible with the Firebase
/// Functions Node.js SDK `logger` namespace.
/// Structured logger for Cloud Logging.
///
/// ## Usage
///
/// ```dart
/// import 'package:firebase_functions/logger.dart';
/// import 'package:firebase_functions/logger.dart' as logger;
///
/// logger.info('Request received');
/// logger.warn('Slow query', {'durationMs': 1200, 'query': 'SELECT ...'});
/// logger.warning('Slow query', payload: {'durationMs': 1200, 'query': 'SELECT ...'});
/// logger.error('Failed to process request');
/// ```
///
/// ## Structured Logging
///
/// Pass a [Map<String, Object?>] as the second argument to include
/// Pass a [Map<String, Object?>] using the named `payload:` argument to include
/// structured data in the Cloud Logging `jsonPayload`:
///
/// ```dart
/// logger.info('User signed in', {
/// logger.info('User signed in', payload: {
/// 'userId': user.id,
/// 'provider': 'google',
/// });
/// ```
///
/// Or pass a [Map] as the sole argument for structured-only entries:
///
/// ```dart
/// logger.info({'message': 'Batch complete', 'processedCount': 42});
/// ```
///
/// ## Severity Routing
///
/// - **stdout**: DEBUG, INFO, NOTICE
/// - **stderr**: WARNING, ERROR, CRITICAL, ALERT, EMERGENCY
library;

export 'src/logger/logger.dart'
hide
cloudTraceContextHeader,
createLogger,
projectIdZoneKey,
traceIdZoneKey;
export 'src/logger/logger.dart';
2 changes: 1 addition & 1 deletion lib/src/common/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import 'dart:convert';
import 'package:shelf/shelf.dart' show Request, Response;
import 'package:stack_trace/stack_trace.dart' show Trace;

import '../../logger.dart' as logger;
import '../https/error.dart';
import '../logger/logger.dart';

Future<Map<String, dynamic>> readAsJsonMap(Request request) async {
final decoded = await _converter.bind(request.read()).first;
Expand Down
7 changes: 5 additions & 2 deletions lib/src/https/callable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'dart:typed_data';

import 'package:shelf/shelf.dart';

import '../logger/logger.dart';
import '../../logger.dart' as logger;
import 'error.dart';

/// JSON decoder function type.
Expand Down Expand Up @@ -264,7 +264,10 @@ class CallableResponse<T extends Object> {
unawaited(sendChunk(result.data));
},
onError: (Object error) {
logger.error('Error in data stream', {'error': error.toString()});
logger.error(
'Error in data stream',
{'error': error.toString()},
);
if (error is HttpsError) {
writeSSE(error.toErrorResponse());
} else {
Expand Down
Loading