Giter Club home page Giter Club logo

Comments (7)

shmuelk avatar shmuelk commented on May 20, 2024 2

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.

NocturnalSolutions avatar NocturnalSolutions commented on May 20, 2024 1

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.

gmosx avatar gmosx commented on May 20, 2024

Nice tips guys, thank you.

@NocturnalSolutions maybe this example should be included in the HeliumLogger README?

from heliumlogger.

shmuelk avatar shmuelk commented on May 20, 2024

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.

NocturnalSolutions avatar NocturnalSolutions commented on May 20, 2024

…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.

shmuelk avatar shmuelk commented on May 20, 2024

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.

helenmasters avatar helenmasters commented on May 20, 2024

@gmosx I've put the code example which is referenced above into the API reference for HeliumStreamLogger here ->

http://ibm-swift.github.io/HeliumLogger/Classes/HeliumStreamLogger.html#/s:12HeliumLogger0a6StreamB0C3usey0B3API0B11MessageTypeO_x06outputC0tFZ

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.