#[non_exhaustive]pub struct LogConfigurationBuilder { /* private fields */ }
Expand description
A builder for LogConfiguration
.
Implementations§
Source§impl LogConfigurationBuilder
impl LogConfigurationBuilder
Sourcepub fn log_driver(self, input: LogDriver) -> Self
pub fn log_driver(self, input: LogDriver) -> Self
The log driver to use for the container.
For tasks on Fargate, the supported log drivers are awslogs
, splunk
, and awsfirelens
.
For tasks hosted on Amazon EC2 instances, the supported log drivers are awslogs
, fluentd
, gelf
, json-file
, journald
, syslog
, splunk
, and awsfirelens
.
For more information about using the awslogs
log driver, see Send Amazon ECS logs to CloudWatch in the Amazon Elastic Container Service Developer Guide.
For more information about using the awsfirelens
log driver, see Send Amazon ECS logs to an Amazon Web Services service or Amazon Web Services Partner.
If you have a custom driver that isn't listed, you can fork the Amazon ECS container agent project that's available on GitHub and customize it to work with that driver. We encourage you to submit pull requests for changes that you would like to have included. However, we don't currently provide support for running modified copies of this software.
Sourcepub fn set_log_driver(self, input: Option<LogDriver>) -> Self
pub fn set_log_driver(self, input: Option<LogDriver>) -> Self
The log driver to use for the container.
For tasks on Fargate, the supported log drivers are awslogs
, splunk
, and awsfirelens
.
For tasks hosted on Amazon EC2 instances, the supported log drivers are awslogs
, fluentd
, gelf
, json-file
, journald
, syslog
, splunk
, and awsfirelens
.
For more information about using the awslogs
log driver, see Send Amazon ECS logs to CloudWatch in the Amazon Elastic Container Service Developer Guide.
For more information about using the awsfirelens
log driver, see Send Amazon ECS logs to an Amazon Web Services service or Amazon Web Services Partner.
If you have a custom driver that isn't listed, you can fork the Amazon ECS container agent project that's available on GitHub and customize it to work with that driver. We encourage you to submit pull requests for changes that you would like to have included. However, we don't currently provide support for running modified copies of this software.
Sourcepub fn get_log_driver(&self) -> &Option<LogDriver>
pub fn get_log_driver(&self) -> &Option<LogDriver>
The log driver to use for the container.
For tasks on Fargate, the supported log drivers are awslogs
, splunk
, and awsfirelens
.
For tasks hosted on Amazon EC2 instances, the supported log drivers are awslogs
, fluentd
, gelf
, json-file
, journald
, syslog
, splunk
, and awsfirelens
.
For more information about using the awslogs
log driver, see Send Amazon ECS logs to CloudWatch in the Amazon Elastic Container Service Developer Guide.
For more information about using the awsfirelens
log driver, see Send Amazon ECS logs to an Amazon Web Services service or Amazon Web Services Partner.
If you have a custom driver that isn't listed, you can fork the Amazon ECS container agent project that's available on GitHub and customize it to work with that driver. We encourage you to submit pull requests for changes that you would like to have included. However, we don't currently provide support for running modified copies of this software.
Sourcepub fn options(self, k: impl Into<String>, v: impl Into<String>) -> Self
pub fn options(self, k: impl Into<String>, v: impl Into<String>) -> Self
Adds a key-value pair to options
.
To override the contents of this collection use set_options
.
The configuration options to send to the log driver.
The options you can specify depend on the log driver. Some of the options you can specify when you use the awslogs
log driver to route logs to Amazon CloudWatch include the following:
- awslogs-create-group
-
Required: No
Specify whether you want the log group to be created automatically. If this option isn't specified, it defaults to
false
.Your IAM policy must include the
logs:CreateLogGroup
permission before you attempt to useawslogs-create-group
. - awslogs-region
-
Required: Yes
Specify the Amazon Web Services Region that the
awslogs
log driver is to send your Docker logs to. You can choose to send all of your logs from clusters in different Regions to a single region in CloudWatch Logs. This is so that they're all visible in one location. Otherwise, you can separate them by Region for more granularity. Make sure that the specified log group exists in the Region that you specify with this option. - awslogs-group
-
Required: Yes
Make sure to specify a log group that the
awslogs
log driver sends its log streams to. - awslogs-stream-prefix
-
Required: Yes, when using Fargate.Optional when using EC2.
Use the
awslogs-stream-prefix
option to associate a log stream with the specified prefix, the container name, and the ID of the Amazon ECS task that the container belongs to. If you specify a prefix with this option, then the log stream takes the formatprefix-name/container-name/ecs-task-id
.If you don't specify a prefix with this option, then the log stream is named after the container ID that's assigned by the Docker daemon on the container instance. Because it's difficult to trace logs back to the container that sent them with just the Docker container ID (which is only available on the container instance), we recommend that you specify a prefix with this option.
For Amazon ECS services, you can use the service name as the prefix. Doing so, you can trace log streams to the service that the container belongs to, the name of the container that sent them, and the ID of the task that the container belongs to.
You must specify a stream-prefix for your logs to have your logs appear in the Log pane when using the Amazon ECS console.
- awslogs-datetime-format
-
Required: No
This option defines a multiline start pattern in Python
strftime
format. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. The matched line is the delimiter between log messages.One example of a use case for using this format is for parsing output such as a stack dump, which might otherwise be logged in multiple entries. The correct pattern allows it to be captured in a single entry.
For more information, see awslogs-datetime-format.
You cannot configure both the
awslogs-datetime-format
andawslogs-multiline-pattern
options.Multiline logging performs regular expression parsing and matching of all log messages. This might have a negative impact on logging performance.
- awslogs-multiline-pattern
-
Required: No
This option defines a multiline start pattern that uses a regular expression. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. The matched line is the delimiter between log messages.
For more information, see awslogs-multiline-pattern.
This option is ignored if
awslogs-datetime-format
is also configured.You cannot configure both the
awslogs-datetime-format
andawslogs-multiline-pattern
options.Multiline logging performs regular expression parsing and matching of all log messages. This might have a negative impact on logging performance.
The following options apply to all supported log drivers.
- mode
-
Required: No
Valid values:
non-blocking
|blocking
This option defines the delivery mode of log messages from the container to the log driver specified using
logDriver
. The delivery mode you choose affects application availability when the flow of logs from container is interrupted.If you use the
blocking
mode and the flow of logs is interrupted, calls from container code to write to thestdout
andstderr
streams will block. The logging thread of the application will block as a result. This may cause the application to become unresponsive and lead to container healthcheck failure.If you use the
non-blocking
mode, the container's logs are instead stored in an in-memory intermediate buffer configured with themax-buffer-size
option. This prevents the application from becoming unresponsive when logs cannot be sent. We recommend using this mode if you want to ensure service availability and are okay with some log loss. For more information, see Preventing log loss with non-blocking mode in theawslogs
container log driver.You can set a default
mode
for all containers in a specific Amazon Web Services Region by using thedefaultLogDriverMode
account setting. If you don't specify themode
option or configure the account setting, Amazon ECS will default to theblocking
mode. For more information about the account setting, see Default log driver mode in the Amazon Elastic Container Service Developer Guide.On June 25, 2025, Amazon ECS is changing the default log driver mode from
blocking
tonon-blocking
to prioritize task availability over logging. To continue using theblocking
mode after this change, do one of the following:-
Set the
mode
option in your container definition'slogConfiguration
asblocking
. -
Set the
defaultLogDriverMode
account setting toblocking
.
-
- max-buffer-size
-
Required: No
Default value:
1m
When
non-blocking
mode is used, themax-buffer-size
log option controls the size of the buffer that's used for intermediate message storage. Make sure to specify an adequate buffer size based on your application. When the buffer fills up, further logs cannot be stored. Logs that cannot be stored are lost.
To route logs using the splunk
log router, you need to specify a splunk-token
and a splunk-url
.
When you use the awsfirelens
log router to route logs to an Amazon Web Services Service or Amazon Web Services Partner Network destination for log storage and analytics, you can set the log-driver-buffer-limit
option to limit the number of events that are buffered in memory, before being sent to the log router container. It can help to resolve potential log loss issue because high throughput might result in memory running out for the buffer inside of Docker.
Other options you can specify when using awsfirelens
to route logs depend on the destination. When you export logs to Amazon Data Firehose, you can specify the Amazon Web Services Region with region
and a name for the log stream with delivery_stream
.
When you export logs to Amazon Kinesis Data Streams, you can specify an Amazon Web Services Region with region
and a data stream name with stream
.
When you export logs to Amazon OpenSearch Service, you can specify options like Name
, Host
(OpenSearch Service endpoint without protocol), Port
, Index
, Type
, Aws_auth
, Aws_region
, Suppress_Type_Name
, and tls
. For more information, see Under the hood: FireLens for Amazon ECS Tasks.
When you export logs to Amazon S3, you can specify the bucket using the bucket
option. You can also specify region
, total_file_size
, upload_timeout
, and use_put_object
as options.
This parameter requires version 1.19 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command: sudo docker version --format '{{.Server.APIVersion}}'
Sourcepub fn set_options(self, input: Option<HashMap<String, String>>) -> Self
pub fn set_options(self, input: Option<HashMap<String, String>>) -> Self
The configuration options to send to the log driver.
The options you can specify depend on the log driver. Some of the options you can specify when you use the awslogs
log driver to route logs to Amazon CloudWatch include the following:
- awslogs-create-group
-
Required: No
Specify whether you want the log group to be created automatically. If this option isn't specified, it defaults to
false
.Your IAM policy must include the
logs:CreateLogGroup
permission before you attempt to useawslogs-create-group
. - awslogs-region
-
Required: Yes
Specify the Amazon Web Services Region that the
awslogs
log driver is to send your Docker logs to. You can choose to send all of your logs from clusters in different Regions to a single region in CloudWatch Logs. This is so that they're all visible in one location. Otherwise, you can separate them by Region for more granularity. Make sure that the specified log group exists in the Region that you specify with this option. - awslogs-group
-
Required: Yes
Make sure to specify a log group that the
awslogs
log driver sends its log streams to. - awslogs-stream-prefix
-
Required: Yes, when using Fargate.Optional when using EC2.
Use the
awslogs-stream-prefix
option to associate a log stream with the specified prefix, the container name, and the ID of the Amazon ECS task that the container belongs to. If you specify a prefix with this option, then the log stream takes the formatprefix-name/container-name/ecs-task-id
.If you don't specify a prefix with this option, then the log stream is named after the container ID that's assigned by the Docker daemon on the container instance. Because it's difficult to trace logs back to the container that sent them with just the Docker container ID (which is only available on the container instance), we recommend that you specify a prefix with this option.
For Amazon ECS services, you can use the service name as the prefix. Doing so, you can trace log streams to the service that the container belongs to, the name of the container that sent them, and the ID of the task that the container belongs to.
You must specify a stream-prefix for your logs to have your logs appear in the Log pane when using the Amazon ECS console.
- awslogs-datetime-format
-
Required: No
This option defines a multiline start pattern in Python
strftime
format. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. The matched line is the delimiter between log messages.One example of a use case for using this format is for parsing output such as a stack dump, which might otherwise be logged in multiple entries. The correct pattern allows it to be captured in a single entry.
For more information, see awslogs-datetime-format.
You cannot configure both the
awslogs-datetime-format
andawslogs-multiline-pattern
options.Multiline logging performs regular expression parsing and matching of all log messages. This might have a negative impact on logging performance.
- awslogs-multiline-pattern
-
Required: No
This option defines a multiline start pattern that uses a regular expression. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. The matched line is the delimiter between log messages.
For more information, see awslogs-multiline-pattern.
This option is ignored if
awslogs-datetime-format
is also configured.You cannot configure both the
awslogs-datetime-format
andawslogs-multiline-pattern
options.Multiline logging performs regular expression parsing and matching of all log messages. This might have a negative impact on logging performance.
The following options apply to all supported log drivers.
- mode
-
Required: No
Valid values:
non-blocking
|blocking
This option defines the delivery mode of log messages from the container to the log driver specified using
logDriver
. The delivery mode you choose affects application availability when the flow of logs from container is interrupted.If you use the
blocking
mode and the flow of logs is interrupted, calls from container code to write to thestdout
andstderr
streams will block. The logging thread of the application will block as a result. This may cause the application to become unresponsive and lead to container healthcheck failure.If you use the
non-blocking
mode, the container's logs are instead stored in an in-memory intermediate buffer configured with themax-buffer-size
option. This prevents the application from becoming unresponsive when logs cannot be sent. We recommend using this mode if you want to ensure service availability and are okay with some log loss. For more information, see Preventing log loss with non-blocking mode in theawslogs
container log driver.You can set a default
mode
for all containers in a specific Amazon Web Services Region by using thedefaultLogDriverMode
account setting. If you don't specify themode
option or configure the account setting, Amazon ECS will default to theblocking
mode. For more information about the account setting, see Default log driver mode in the Amazon Elastic Container Service Developer Guide.On June 25, 2025, Amazon ECS is changing the default log driver mode from
blocking
tonon-blocking
to prioritize task availability over logging. To continue using theblocking
mode after this change, do one of the following:-
Set the
mode
option in your container definition'slogConfiguration
asblocking
. -
Set the
defaultLogDriverMode
account setting toblocking
.
-
- max-buffer-size
-
Required: No
Default value:
1m
When
non-blocking
mode is used, themax-buffer-size
log option controls the size of the buffer that's used for intermediate message storage. Make sure to specify an adequate buffer size based on your application. When the buffer fills up, further logs cannot be stored. Logs that cannot be stored are lost.
To route logs using the splunk
log router, you need to specify a splunk-token
and a splunk-url
.
When you use the awsfirelens
log router to route logs to an Amazon Web Services Service or Amazon Web Services Partner Network destination for log storage and analytics, you can set the log-driver-buffer-limit
option to limit the number of events that are buffered in memory, before being sent to the log router container. It can help to resolve potential log loss issue because high throughput might result in memory running out for the buffer inside of Docker.
Other options you can specify when using awsfirelens
to route logs depend on the destination. When you export logs to Amazon Data Firehose, you can specify the Amazon Web Services Region with region
and a name for the log stream with delivery_stream
.
When you export logs to Amazon Kinesis Data Streams, you can specify an Amazon Web Services Region with region
and a data stream name with stream
.
When you export logs to Amazon OpenSearch Service, you can specify options like Name
, Host
(OpenSearch Service endpoint without protocol), Port
, Index
, Type
, Aws_auth
, Aws_region
, Suppress_Type_Name
, and tls
. For more information, see Under the hood: FireLens for Amazon ECS Tasks.
When you export logs to Amazon S3, you can specify the bucket using the bucket
option. You can also specify region
, total_file_size
, upload_timeout
, and use_put_object
as options.
This parameter requires version 1.19 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command: sudo docker version --format '{{.Server.APIVersion}}'
Sourcepub fn get_options(&self) -> &Option<HashMap<String, String>>
pub fn get_options(&self) -> &Option<HashMap<String, String>>
The configuration options to send to the log driver.
The options you can specify depend on the log driver. Some of the options you can specify when you use the awslogs
log driver to route logs to Amazon CloudWatch include the following:
- awslogs-create-group
-
Required: No
Specify whether you want the log group to be created automatically. If this option isn't specified, it defaults to
false
.Your IAM policy must include the
logs:CreateLogGroup
permission before you attempt to useawslogs-create-group
. - awslogs-region
-
Required: Yes
Specify the Amazon Web Services Region that the
awslogs
log driver is to send your Docker logs to. You can choose to send all of your logs from clusters in different Regions to a single region in CloudWatch Logs. This is so that they're all visible in one location. Otherwise, you can separate them by Region for more granularity. Make sure that the specified log group exists in the Region that you specify with this option. - awslogs-group
-
Required: Yes
Make sure to specify a log group that the
awslogs
log driver sends its log streams to. - awslogs-stream-prefix
-
Required: Yes, when using Fargate.Optional when using EC2.
Use the
awslogs-stream-prefix
option to associate a log stream with the specified prefix, the container name, and the ID of the Amazon ECS task that the container belongs to. If you specify a prefix with this option, then the log stream takes the formatprefix-name/container-name/ecs-task-id
.If you don't specify a prefix with this option, then the log stream is named after the container ID that's assigned by the Docker daemon on the container instance. Because it's difficult to trace logs back to the container that sent them with just the Docker container ID (which is only available on the container instance), we recommend that you specify a prefix with this option.
For Amazon ECS services, you can use the service name as the prefix. Doing so, you can trace log streams to the service that the container belongs to, the name of the container that sent them, and the ID of the task that the container belongs to.
You must specify a stream-prefix for your logs to have your logs appear in the Log pane when using the Amazon ECS console.
- awslogs-datetime-format
-
Required: No
This option defines a multiline start pattern in Python
strftime
format. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. The matched line is the delimiter between log messages.One example of a use case for using this format is for parsing output such as a stack dump, which might otherwise be logged in multiple entries. The correct pattern allows it to be captured in a single entry.
For more information, see awslogs-datetime-format.
You cannot configure both the
awslogs-datetime-format
andawslogs-multiline-pattern
options.Multiline logging performs regular expression parsing and matching of all log messages. This might have a negative impact on logging performance.
- awslogs-multiline-pattern
-
Required: No
This option defines a multiline start pattern that uses a regular expression. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. The matched line is the delimiter between log messages.
For more information, see awslogs-multiline-pattern.
This option is ignored if
awslogs-datetime-format
is also configured.You cannot configure both the
awslogs-datetime-format
andawslogs-multiline-pattern
options.Multiline logging performs regular expression parsing and matching of all log messages. This might have a negative impact on logging performance.
The following options apply to all supported log drivers.
- mode
-
Required: No
Valid values:
non-blocking
|blocking
This option defines the delivery mode of log messages from the container to the log driver specified using
logDriver
. The delivery mode you choose affects application availability when the flow of logs from container is interrupted.If you use the
blocking
mode and the flow of logs is interrupted, calls from container code to write to thestdout
andstderr
streams will block. The logging thread of the application will block as a result. This may cause the application to become unresponsive and lead to container healthcheck failure.If you use the
non-blocking
mode, the container's logs are instead stored in an in-memory intermediate buffer configured with themax-buffer-size
option. This prevents the application from becoming unresponsive when logs cannot be sent. We recommend using this mode if you want to ensure service availability and are okay with some log loss. For more information, see Preventing log loss with non-blocking mode in theawslogs
container log driver.You can set a default
mode
for all containers in a specific Amazon Web Services Region by using thedefaultLogDriverMode
account setting. If you don't specify themode
option or configure the account setting, Amazon ECS will default to theblocking
mode. For more information about the account setting, see Default log driver mode in the Amazon Elastic Container Service Developer Guide.On June 25, 2025, Amazon ECS is changing the default log driver mode from
blocking
tonon-blocking
to prioritize task availability over logging. To continue using theblocking
mode after this change, do one of the following:-
Set the
mode
option in your container definition'slogConfiguration
asblocking
. -
Set the
defaultLogDriverMode
account setting toblocking
.
-
- max-buffer-size
-
Required: No
Default value:
1m
When
non-blocking
mode is used, themax-buffer-size
log option controls the size of the buffer that's used for intermediate message storage. Make sure to specify an adequate buffer size based on your application. When the buffer fills up, further logs cannot be stored. Logs that cannot be stored are lost.
To route logs using the splunk
log router, you need to specify a splunk-token
and a splunk-url
.
When you use the awsfirelens
log router to route logs to an Amazon Web Services Service or Amazon Web Services Partner Network destination for log storage and analytics, you can set the log-driver-buffer-limit
option to limit the number of events that are buffered in memory, before being sent to the log router container. It can help to resolve potential log loss issue because high throughput might result in memory running out for the buffer inside of Docker.
Other options you can specify when using awsfirelens
to route logs depend on the destination. When you export logs to Amazon Data Firehose, you can specify the Amazon Web Services Region with region
and a name for the log stream with delivery_stream
.
When you export logs to Amazon Kinesis Data Streams, you can specify an Amazon Web Services Region with region
and a data stream name with stream
.
When you export logs to Amazon OpenSearch Service, you can specify options like Name
, Host
(OpenSearch Service endpoint without protocol), Port
, Index
, Type
, Aws_auth
, Aws_region
, Suppress_Type_Name
, and tls
. For more information, see Under the hood: FireLens for Amazon ECS Tasks.
When you export logs to Amazon S3, you can specify the bucket using the bucket
option. You can also specify region
, total_file_size
, upload_timeout
, and use_put_object
as options.
This parameter requires version 1.19 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command: sudo docker version --format '{{.Server.APIVersion}}'
Sourcepub fn secret_options(self, input: Secret) -> Self
pub fn secret_options(self, input: Secret) -> Self
Appends an item to secret_options
.
To override the contents of this collection use set_secret_options
.
The secrets to pass to the log configuration. For more information, see Specifying sensitive data in the Amazon Elastic Container Service Developer Guide.
Sourcepub fn set_secret_options(self, input: Option<Vec<Secret>>) -> Self
pub fn set_secret_options(self, input: Option<Vec<Secret>>) -> Self
The secrets to pass to the log configuration. For more information, see Specifying sensitive data in the Amazon Elastic Container Service Developer Guide.
Sourcepub fn get_secret_options(&self) -> &Option<Vec<Secret>>
pub fn get_secret_options(&self) -> &Option<Vec<Secret>>
The secrets to pass to the log configuration. For more information, see Specifying sensitive data in the Amazon Elastic Container Service Developer Guide.
Sourcepub fn build(self) -> Result<LogConfiguration, BuildError>
pub fn build(self) -> Result<LogConfiguration, BuildError>
Consumes the builder and constructs a LogConfiguration
.
This method will fail if any of the following fields are not set:
Trait Implementations§
Source§impl Clone for LogConfigurationBuilder
impl Clone for LogConfigurationBuilder
Source§fn clone(&self) -> LogConfigurationBuilder
fn clone(&self) -> LogConfigurationBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LogConfigurationBuilder
impl Debug for LogConfigurationBuilder
Source§impl Default for LogConfigurationBuilder
impl Default for LogConfigurationBuilder
Source§fn default() -> LogConfigurationBuilder
fn default() -> LogConfigurationBuilder
Source§impl PartialEq for LogConfigurationBuilder
impl PartialEq for LogConfigurationBuilder
impl StructuralPartialEq for LogConfigurationBuilder
Auto Trait Implementations§
impl Freeze for LogConfigurationBuilder
impl RefUnwindSafe for LogConfigurationBuilder
impl Send for LogConfigurationBuilder
impl Sync for LogConfigurationBuilder
impl Unpin for LogConfigurationBuilder
impl UnwindSafe for LogConfigurationBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);