@@ -27,13 +27,17 @@ defmodule Cadet.Logger.CloudWatchLogger do
2727 @ impl true
2828 def init ( { __MODULE__ , opts } ) when is_list ( opts ) do
2929 config = configure_merge ( read_env ( ) , opts )
30- { :ok , init ( config , % __MODULE__ { } ) }
30+ state = init ( config , % __MODULE__ { } )
31+ ensure_log_stream_exists ( state . log_group , state . log_stream )
32+ { :ok , state }
3133 end
3234
3335 @ impl true
3436 def init ( { __MODULE__ , name } ) when is_atom ( name ) do
3537 config = read_env ( )
36- { :ok , init ( config , % __MODULE__ { } ) }
38+ state = init ( config , % __MODULE__ { } )
39+ ensure_log_stream_exists ( state . log_group , state . log_stream )
40+ { :ok , state }
3741 end
3842
3943 @ impl true
@@ -151,8 +155,7 @@ defmodule Cadet.Logger.CloudWatchLogger do
151155
152156 defp send_to_cloudwatch ( log_stream , log_group , buffer ) do
153157 # Ensure that the already have ExAws authentication configured
154- with :ok <- check_exaws_config ( ) ,
155- :ok <- ensure_log_stream_exists ( log_group , log_stream ) do
158+ with :ok <- check_exaws_config ( ) do
156159 operation = build_log_operation ( log_stream , log_group , buffer )
157160
158161 operation
0 commit comments