-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8201d1
commit a4f92eb
Showing
20 changed files
with
84 additions
and
43 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- `console_example.dart` - Shows how to set up a logger to log to the console | ||
- `file_example.dart` - Demonstrates how to configure log records to be written to a file | ||
- `file_rotation_periodic_example.dart` - Shows how to set up file logging with a time-based rotation policy | ||
- `file_rotation_periodic_sized_example.dart` - Shows how to set up logging to a file with size-based rotation policy | ||
- `global_logger_example.dart` - Demonstrates how to use a global logger | ||
- `global_logger_override_example.dart` - Demonstrates how to replace the default global logger | ||
- `hierarchy/` - Demonstrates a simple hierarchy of loggers | ||
- `pretty_console_example.dart` - Shows how to setup a prettified console logger with colors | ||
- `simple_example.dart` - Shows how to simply log to the console | ||
- `stdout_stderr_example.dart` - Demonstrates how to filter log records and direct them to stdout/stderr based on severity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:strlog/strlog.dart' | ||
show Logger, Loggable, Str, Obj, Field, DefaultLog; | ||
|
||
// A child logger of logger with namespace `strlog.example.hierarchy`. | ||
final logger = Logger.getLogger('strlog.example.hierarchy.get_user'); | ||
|
||
class User implements Loggable { | ||
const User(this.name, this.email); | ||
|
||
final String name; | ||
final String email; | ||
|
||
@override | ||
Iterable<Field> toFields() => ({Str('email', email), Str('name', name)}); | ||
} | ||
|
||
User getUser() { | ||
logger.info('Fetching user...'); | ||
final user = User('Roman', '[email protected]'); | ||
logger.info('Fetched user', {Obj('user', user)}); | ||
|
||
return user; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:strlog/strlog.dart' show Logger; | ||
import 'package:strlog/handlers.dart' show ConsoleHandler; | ||
import 'package:strlog/formatters.dart' show TextFormatter; | ||
|
||
// Define logger namespace | ||
final logger = Logger.getLogger('strlog.example.hierarchy') | ||
..handler = ConsoleHandler(formatter: TextFormatter.withDefaults().call); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// This example demonstrates a simple hierarchy of loggers. | ||
/// All child loggers of the logger with the `strlog.example.hierarchy` namespace | ||
/// should propagate records to it, resulting in all records from child loggers | ||
/// being logged to the console. | ||
library; | ||
|
||
import 'package:strlog/strlog.dart' show Logger, DefaultLog, Str; | ||
import 'package:strlog/handlers.dart' show ConsoleHandler; | ||
import 'package:strlog/formatters.dart' show TextFormatter; | ||
import './get_user.dart'; | ||
|
||
void main() { | ||
// Define logger namespace | ||
final logger = Logger.getLogger('strlog.example.hierarchy') | ||
..handler = ConsoleHandler(formatter: TextFormatter.withDefaults().call); | ||
|
||
final user = getUser(); | ||
|
||
logger.info('User email', {Str('user_email', user.email)}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ final class _LazyObj extends _LazyField<Iterable<Field>?> implements Obj { | |
: super(name: name, producer: producer, kind: FieldKind.object); | ||
} | ||
|
||
/// A field with value of custom type (i.e. class that implements | ||
/// A field with a value of a custom type (i.e., a class that implements | ||
/// [Loggable]). | ||
abstract class Obj extends Field<Iterable<Field>?> { | ||
factory Obj(String name, Loggable? value) => _StaticObj(name, value); | ||
|
@@ -19,7 +19,7 @@ abstract class Obj extends Field<Iterable<Field>?> { | |
_LazyObj(name, () => producer()?.toFields()); | ||
} | ||
|
||
/// [Loggable] provides the ability to object to be logged as part of | ||
/// [Loggable] provides the ability for an object to be logged as part of a | ||
/// logging context field set. | ||
/// | ||
/// Example: | ||
|
@@ -42,11 +42,11 @@ abstract class Obj extends Field<Iterable<Field>?> { | |
/// | ||
/// final user = User( | ||
/// name: 'Roman Vanesyan', | ||
/// email: '[email protected]', | ||
/// email: '[email protected]', | ||
/// createdAt: DateTime.now()); | ||
/// | ||
/// logger | ||
/// .bind(Obj('user', user), DTM('authenticatedAt', DateTime.now())) | ||
/// .bind(Obj('user', user), DTM('authenticated_at', DateTime.now())) | ||
/// .info('successfully authenticated'); | ||
/// ``` | ||
abstract class Loggable { | ||
|
This file was deleted.
Oops, something went wrong.