@@ -914,7 +914,7 @@ def test_log_error_standard_log_sink(self, mock_stdout):
914
914
915
915
def test_log_error_framed_log_sink (self ):
916
916
with NamedTemporaryFile () as temp_file :
917
- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as log_sink :
917
+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as log_sink :
918
918
err_to_log = bootstrap .make_error ("Error message" , "ErrorType" , None )
919
919
bootstrap .log_error (err_to_log , log_sink )
920
920
@@ -949,7 +949,7 @@ def test_log_error_indentation_standard_log_sink(self, mock_stdout):
949
949
950
950
def test_log_error_indentation_framed_log_sink (self ):
951
951
with NamedTemporaryFile () as temp_file :
952
- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as log_sink :
952
+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as log_sink :
953
953
err_to_log = bootstrap .make_error (
954
954
"Error message" , "ErrorType" , [" line1 " , " line2 " , " " ]
955
955
)
@@ -984,7 +984,7 @@ def test_log_error_empty_stacktrace_line_standard_log_sink(self, mock_stdout):
984
984
985
985
def test_log_error_empty_stacktrace_line_framed_log_sink (self ):
986
986
with NamedTemporaryFile () as temp_file :
987
- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as log_sink :
987
+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as log_sink :
988
988
err_to_log = bootstrap .make_error (
989
989
"Error message" , "ErrorType" , ["line1" , "" , "line2" ]
990
990
)
@@ -1070,19 +1070,19 @@ def test_create_unbuffered_log_sinks(self, mock_stdout):
1070
1070
self .assertEqual (mock_stdout .getvalue (), "log" )
1071
1071
1072
1072
def test_create_framed_telemetry_log_sinks (self ):
1073
- fd = "test_fd"
1074
- os .environ ["_LAMBDA_TELEMETRY_LOG_FD" ] = fd
1073
+ fd = 3
1074
+ os .environ ["_LAMBDA_TELEMETRY_LOG_FD" ] = "3"
1075
1075
1076
1076
actual = bootstrap .create_log_sink ()
1077
1077
1078
1078
self .assertIsInstance (actual , bootstrap .FramedTelemetryLogSink )
1079
- self .assertEqual (actual .filename , "/proc/self/fd/" + fd )
1079
+ self .assertEqual (actual .fd , fd )
1080
1080
self .assertFalse ("_LAMBDA_TELEMETRY_LOG_FD" in os .environ )
1081
1081
1082
1082
def test_single_frame (self ):
1083
1083
with NamedTemporaryFile () as temp_file :
1084
1084
message = "hello world\n something on a new line!\n "
1085
- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as ls :
1085
+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as ls :
1086
1086
ls .log (message )
1087
1087
with open (temp_file .name , "rb" ) as f :
1088
1088
content = f .read ()
@@ -1101,7 +1101,7 @@ def test_multiple_frame(self):
1101
1101
first_message = "hello world\n something on a new line!"
1102
1102
second_message = "hello again\n here's another message\n "
1103
1103
1104
- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as ls :
1104
+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as ls :
1105
1105
ls .log (first_message )
1106
1106
ls .log (second_message )
1107
1107
0 commit comments