Comments (7)
If you want more sophisticated logging than that which is provided by HeliumLogger, I'd suggest you look at https://github.com/SwiftyBeaver/SwiftyBeaver-Kitura.
from heliumlogger.
HeliumLogger lets you log to implementations of TextOutputStream. See HeliumStreamLogger.swift.
Here's some code I threw together to log to stderr (thanks to https://deepswift.com/core/standard-io/ ) which ensures that the logging is still visible when running tests. You can probably see where you can adapt it to write to a text file instead.
struct StandardError: TextOutputStream {
func write(_ text: String) {
guard let data = text.data(using: String.Encoding.utf8) else {
return
}
FileHandle.standardError.write(data)
}
}
let se = StandardError()
HeliumStreamLogger.use(outputStream: se)
Then log as normal.
from heliumlogger.
Nice tips guys, thank you.
@NocturnalSolutions maybe this example should be included in the HeliumLogger README?
from heliumlogger.
In general logging to files is more involved than just writing to a file. Generally to be useful one needs log rotation (one hopes one's server will run for a really long time which makes for very large log files...) and some minimal management to insure that the file system doesn't fill up with log files......
from heliumlogger.
…but sometimes one just needs to see what's going on in one's code and a debugger isn't a good fit for certain cases. And any server OS worth being called as much will already ship with log rotation tools if one really needs to log so much stuff in production that filling up a disk is a worry.
Are you really a contributor to this project? You seem to be very interested in talking us down from using it in favor of a commercial alternative. Hmm.
from heliumlogger.
I am a contributor to Kitura.
The goal of HeliumLogger was to be a very simple and lightweight logger. The idea of the LoggerAPI in Kitura was to enable the plugging in of all sorts of loggers, not just those supplied by Kitura.
Even open source servers that log to disk, have built in facilities to switch log files when the log file is over a certain size.
I agree that sometimes simplistic logging to a file is useful.
from heliumlogger.
@gmosx I've put the code example which is referenced above into the API reference for HeliumStreamLogger here ->
If this resolves your issue please can you close it. If it doesn't and you'd like additional documentation please let me know what and where and I'll address it.
from heliumlogger.
Related Issues (20)
- Create unit tests for HeliumLogger
- Setup CI for HeliumLogger HOT 2
- Dependencies HOT 1
- How to log to file?#Question HOT 3
- Ability to optionally turn off code coloring HOT 2
- import LoggerAPI is required too HOT 5
- how to use your module in project? HOT 2
- Add .swift-sample HOT 1
- Set log file path HOT 1
- Set log file path
- The dependency graph could not be satisfied (https://github.com/IBM-Swift/HeliumLogger.git) HOT 10
- Error when building on Ubuntu 16.10 with Swift 3.0.2 HOT 1
- fail to staging swift application with latest 1.7.0 version HOT 4
- Document log output (in readme) HOT 1
- JSON output
- PackageDescription API v3 deprecation warning HOT 7
- Any native configuration for log rotation in the API ? HOT 1
- README does not describe how to set LOG_LEVEL when using with Swift-log HOT 2
- feature: log swift queue name HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heliumlogger.