All Projects → Kitura → Heliumlogger

Kitura / Heliumlogger

Licence: apache-2.0
A lightweight logging framework for Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Heliumlogger

Golog
A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.
Stars: ✭ 208 (+23.08%)
Mutual labels:  logging, log, logger
Node Lambda Log
Basic logging mechanism for Node 6.10+ Lambda Functions
Stars: ✭ 115 (-31.95%)
Mutual labels:  logging, log, logger
gxlog
A concise, functional, flexible and extensible logger for go.
Stars: ✭ 65 (-61.54%)
Mutual labels:  log, logger, logging
Serverlog
A simple, practical and innovative Node.js log library that enables you to view logs in Chrome dev tools and browser Console.
Stars: ✭ 117 (-30.77%)
Mutual labels:  logging, log, logger
Yii2 Psr Log Target
Yii 2.0 log target that is able to write messages to PSR-3 compatible logger
Stars: ✭ 58 (-65.68%)
Mutual labels:  logging, log, logger
Monolog Bundle
Symfony Monolog Bundle
Stars: ✭ 2,532 (+1398.22%)
Mutual labels:  logging, log, logger
Gollum
An n:m message multiplexer written in Go
Stars: ✭ 883 (+422.49%)
Mutual labels:  logging, log, logger
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+2130.18%)
Mutual labels:  logging, log, logger
Plog
Portable, simple and extensible C++ logging library
Stars: ✭ 1,061 (+527.81%)
Mutual labels:  logging, log, logger
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-69.82%)
Mutual labels:  logging, log, logger
Logcat
Android 日志打印框架,在手机上可以直接看到 Logcat 日志啦
Stars: ✭ 189 (+11.83%)
Mutual labels:  logging, log, logger
Loguru
Python logging made (stupidly) simple
Stars: ✭ 10,510 (+6118.93%)
Mutual labels:  logging, log, logger
Acho
The Hackable Log
Stars: ✭ 189 (+11.83%)
Mutual labels:  logging, log, logger
Easylogger
An ultra-lightweight(ROM<1.6K, RAM<0.3k), high-performance C/C++ log library. | 一款超轻量级(ROM<1.6K, RAM<0.3k)、高性能的 C/C++ 日志库
Stars: ✭ 1,968 (+1064.5%)
Mutual labels:  logging, log, logger
Loglevelnext
A modern logging library for Node.js that provides log level mapping to the console
Stars: ✭ 33 (-80.47%)
Mutual labels:  logging, log, logger
Android Filelogger
A general-purpose logging library with built-in support to save logs to file efficiently.
Stars: ✭ 70 (-58.58%)
Mutual labels:  logging, log, logger
Quicklogger
Library for logging on files, console, memory, email, rest, eventlog, syslog, slack, telegram, redis, logstash, elasticsearch, influxdb, graylog, Sentry, Twilio, ide debug messages and throw events for Delphi/Firemonkey/freepascal/.NET (Windows/Linux/OSX/IOS/Android).
Stars: ✭ 137 (-18.93%)
Mutual labels:  logging, log, logger
Logback Access Spring Boot Starter
Spring Boot Starter for Logback-access
Stars: ✭ 118 (-30.18%)
Mutual labels:  logging, logger
Plug logger json
Elixir Plug that formats http request logs as json
Stars: ✭ 125 (-26.04%)
Mutual labels:  logging, logger
Silencer
Easily suppress the Rails logger
Stars: ✭ 116 (-31.36%)
Mutual labels:  logging, logger

Kitura

APIDoc Build Status - Master codecov macOS Linux Apache 2 Slack Status

HeliumLogger

Provides a lightweight logging implementation for Swift which logs to standard output.

Features

Usage

Add dependencies

Add the HeliumLogger package to the dependencies within your application’s Package.swift file. Substitute "x.x.x" with the latest HeliumLogger release.

.package(url: "https://github.com/Kitura/HeliumLogger.git", from: "x.x.x")

Add HeliumLogger to your target's dependencies:

.target(name: "example", dependencies: ["HeliumLogger"]),

Import packages

To use with LoggerAPI:

import HeliumLogger
import LoggerAPI

To use with swift-log:

import HeliumLogger
import Logging

Initialize HeliumLogger

To use HeliumLogger as a logging backend for LoggerAPI:

let logger = HeliumLogger()
Log.logger = logger

or, if you don't need to customize HeliumLogger:

HeliumLogger.use()

To use HeliumLogger as a logging backend for swift-log:

let logger = HeliumLogger()
LoggingSystem.bootstrap(logger.makeLogHandler)

Or, as a convenience:

HeliumLogger.bootstrapSwiftLog()

Logging levels

You can specify the level of output on initialization. You will see output of that level, and all levels below that.

The order is:

  1. entry (entering a function)
  2. exit (exiting a function)
  3. debug
  4. verbose (default)
  5. info
  6. warning
  7. error

For example, this logger will show messages of type verbose, info, warning, and error:

let logger = HeliumLogger(.verbose)
Log.logger = logger

In this example, the logger will only show messages of type warning and error:

HeliumLogger.use(.warning)

Note that when HeliumLogger is used in conjunction with swift-log, the logging level is determined by the Logger, and HeliumLogger's own logging level is unused.

Adjust logging levels at runtime (LoggerAPI)

Calling HeliumLogger.use(LoggerMessageType) will set the LoggerAPI to use this new HeliumLogger instance. If in a route you detect an error with your application, you could use this to dynamically increase the log level.

This new instance will not have any customization which you applied to other instances (see list item 7).

Logging messages (LoggerAPI)

How to use HeliumLogger to log messages in your application with LoggerAPI:

Log.verbose("This is a verbose log message.")

Log.info("This is an informational log message.")

Log.warning("This is a warning.")

Log.error("This is an error.")

Log.debug("This is a debug message.")

Further customization

/// Whether, if true, or not the logger output should be colorized.
public var colored: Bool = false

/// If true, use the detailed format when a user logging format wasn't specified.
public var details: Bool = true

/// If true, use the full file path, not just the filename.
public var fullFilePath: Bool = false

/// If not nil, specifies the user specified logging format.
/// For example: "[(%date)] [(%type)] [(%file):(%line) (%func)] (%msg)"
public var format: String?

/// If not nil, specifies the format used when adding the date and the time to the logged messages.
public var dateFormat: String?

/// If not nil, specifies the timezone used in the date time format.
public var timeZone: TimeZone?

API documentation

For more information visit our API reference.

Community

We love to talk server-side Swift, and Kitura. Join our Slack to meet the team!

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].