-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from cwakamo/prevent-recursive-logging-4.2
[4.2] [PlaygroundLogger] Add checks in the logger entrypoints to prevent recursive logging.
- Loading branch information
Showing
9 changed files
with
241 additions
and
6 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
PlaygroundLogger/PlaygroundLogger/Utilities/PGLThreadIsLogging.h
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,37 @@ | ||
//===--- PGLThreadIsLogging.h ---------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2018 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#import <sys/cdefs.h> | ||
#import <stdbool.h> | ||
|
||
__BEGIN_DECLS | ||
|
||
/// A thread-local `bool` which indicates whether or not the current thread is | ||
/// logging. | ||
/// | ||
/// This is used by the functions in LoggerEntrypoints.swift and | ||
/// LegacyEntrypoints.swift to prevent generating log packets while already | ||
/// generating a log packet. It means the side-effects of logging are not | ||
/// themselves logged. | ||
extern __thread bool PGLThreadIsLogging; | ||
|
||
/// A helper function to get the value of `PGLThreadIsLogging` safely from Swift. | ||
static inline bool PGLGetThreadIsLogging(void) { | ||
return PGLThreadIsLogging; | ||
} | ||
|
||
/// A helper function to set the value of `PGLThreadIsLogging` safely from Swift. | ||
static inline void PGLSetThreadIsLogging(bool threadIsLogging) { | ||
PGLThreadIsLogging = threadIsLogging; | ||
} | ||
|
||
__END_DECLS |
15 changes: 15 additions & 0 deletions
15
PlaygroundLogger/PlaygroundLogger/Utilities/PGLThreadIsLogging.m
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,15 @@ | ||
//===--- PGLThreadIsLogging.m ---------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2018 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#import <PlaygroundLogger/PGLThreadIsLogging.h> | ||
|
||
__thread bool PGLThreadIsLogging = false; |
Oops, something went wrong.