Rainbow alternatives and similar libraries
Based on the "Logging" category.
Alternatively, view Rainbow alternatives based on common mentions on social networks and blogs.
SwiftyBeaver9.5 2.1 L4 Rainbow VS SwiftyBeaverConvenient & secure logging during development & release in Swift 4 & 5
XCGLogger9.3 0.0 L3 Rainbow VS XCGLoggerA debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Dotzu8.3 0.0 L5 Rainbow VS DotzuDebbuger tool for iOS developer. Display logs, network request, device informations, crash logs while using the app.
TinyConsole8.2 0.0 L5 Rainbow VS TinyConsole📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
Watchdog8.1 0.0 Rainbow VS WatchdogClass for logging excessive blocking on the main thread
CleanroomLogger7.7 0.0 L4 Rainbow VS CleanroomLoggerCleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant
Willow7.6 0.0 L5 Rainbow VS WillowWillow is a powerful, yet lightweight logging library written in Swift.
QorumLogs6.7 0.0 L4 Rainbow VS QorumLogs:closed_book: Swift Logging Utility for Xcode & Google Docs
Log6.6 0.0 L4 Rainbow VS LogAn extensible logging framework for Swift
WatchdogInspector5.4 2.5 Rainbow VS WatchdogInspectorShows your current framerate (fps) in the status bar of your iOS app
Gedatsu5.4 0.0 Rainbow VS GedatsuGedatsu provide readable format about AutoLayout error console log
Swell4.8 0.0 L4 Rainbow VS SwellLogging utility for Swift and Objective C
Duration4.5 1.9 L5 Rainbow VS DurationA simple Swift package for measuring and reporting the time taken for operations
HeliumLogger4.1 0.0 L4 Rainbow VS HeliumLoggerA lightweight logging framework for Swift
Puree3.6 0.0 Rainbow VS Puree[Obsoleted] A log collector for iOS (new version! -> https://github.com/cookpad/Puree-Swift)
Atlantis3.5 0.0 L3 Rainbow VS AtlantisA powerful input-agnostic swift logging framework made to speed up development with maximum readability.
AEConsole3.2 0.0 L5 Rainbow VS AEConsoleCustomizable Console UI overlay with debug log on top of your iOS App
Bugfender2.9 0.0 Rainbow VS BugfenderBugfender SDK for iOS, a remote logger tailor-made for mobile
Puppy2.7 1.6 Rainbow VS PuppyA flexible logging library written in Swift
CleanroomASL2.5 0.0 L3 Rainbow VS CleanroomASLA Swift-based API for reading from & writing to the Apple System Log (more commonly known somewhat inaccurately as "the console")
TraceLog2.0 1.0 Rainbow VS TraceLogTraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.
Evergreen2.0 0.0 L4 Rainbow VS EvergreenMost natural Swift logging
Printer1.8 0.0 Rainbow VS PrinterA fancy logger yet lightweight, and configurable. 🖨
AELog1.0 0.0 L5 Rainbow VS AELogSimple, lightweight and flexible debug logging framework written in Swift
LogDog0.6 0.3 Rainbow VS LogDoguser-friendly logging
swiftRemoteLogger0.3 0.0 Rainbow VS swiftRemoteLoggerSwift Remote Logger tool
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Rainbow or a related project?
Rainbow adds text color, background color and style for console and command
line output in Swift. It is born for cross-platform software logging
in terminals, working in both Apple's platforms and Linux.
Nifty way, using the
String extension, and print the colorized string.
Named Color & Style
import Rainbow print("Red text".red) print("Blue background".onBlue) print("Light green text on white background".lightGreen.onWhite) print("Underline".underline) print("Cyan with bold and blinking".cyan.bold.blink) print("Plain text".red.onYellow.bold.clearColor.clearBackgroundColor.clearStyles)
It gives you something like this:
Swift Package Manager
If you are developing a cross platform software in Swift,
Swift Package Manager might
be your choice for package management. Just add the url of this repo to your
Package.swift file as a dependency:
import PackageDescription let package = Package( name: "YourAwesomeSoftware", dependencies: [ .package(url: "https://github.com/onevcat/Rainbow", .upToNextMajor(from: "4.0.0")) ], targets: [ .target( name: "MyApp", dependencies: ["Rainbow"] ) ] )
swift build whenever you get prepared.
You could know more information on how to use Swift Package Manager in Apple's official page.
String Interpolation & Nested
Swift string interpolation is supported. Define the color for part of the string. Or even create nested colorful strings. The inner color style will be kept:
ANSI 256-Color Mode
8-bit color is fully supported, for both text color and background color:
Hex Colors (approximated)
It also accepts a Hex color. Rainbow tries to convert it to a most approximate
A few terminal emulators supports 24-bit true color. If you are sure the 24-bit colors can be displayed in your user's terminal, Rainbow has no reason to refuse them!
print("疏影横斜\("水清浅".bit24(36,116,181))，暗香浮动\("月黄昏".bit24(254,215,26))") print("\("春色满园".hex("#ea517f", to: .bit24))关不住，\("一枝红杏".hex("#f43e06", to: .bit24))出墙来。")
By default, Rainbow should be smart enough to detect the output target, to determine if it is a tty. For example, it automatically output plain text if written to a file:
// main.swift print("Hello Rainbow".red) $ .build/debug/RainbowDemo > output.txt // output.txt Hello Rainbow
This is useful for sharing the same code for logging to console and to a log file.
You can manually change this behavior by either:
- Set the
- Pass a
"NO_COLOR"environment value when executing your app.
- Or set the
You can also use the more verbose way if you want:
import Rainbow let output = "The quick brown fox jumps over the lazy dog" .applyingCodes(Color.red, BackgroundColor.yellow, Style.bold) print(output) // Red text on yellow, bold of course :)
Or even construct everything from scratch:
let entry = Rainbow.Entry( segments: [ .init(text: "Hello ", color: .named(.magenta)), .init(text: "Rainbow", color: .bit8(214), backgroundColor: .named(.lightBlue), styles: [.underline]), ] ) print(Rainbow.generateString(for: entry))
Please remember, the string extensions (such as
O(n). So if you are handling a huge string or very
complex nesting, there might be a performance issue or hard to make things in stream. The manual way is a rescue for these
Motivation and Compatibility
Thanks to the open source of Swift, developers now could write cross platform programs with the same language. And I believe the command line software would be the next great platform for Swift. Colorful and well-organized output always helps us to understand what happens. It is really a necessary utility to create wonderful software.
Rainbow should work well in both OS X and Linux terminals. It is smart enough
to check whether the output is connected to a valid text terminal or not, to
decide the log should be modified or not. This could be useful when you want to
send your log to a file instead to console.
Follow and contact me on Twitter or Sina Weibo. If you find an issue, just open a ticket on it. Pull requests are warmly welcome as well.
Backers & Sponsors
Open-source projects cannot live long without your help. If you find Kingfisher is useful, please consider supporting this project by becoming a sponsor. Your user icon or company logo shows up on my blog with a link to your home page.
Become a sponsor through GitHub Sponsors. :heart:
Rainbow is released under the MIT license. See LICENSE for details.
*Note that all licence references and agreements mentioned in the Rainbow README section above are relevant to that project's source code only.