Git Product home page Git Product logo

loggerapiz's Introduction

Kitura

APIDoc Build Status - Master macOS Linux Apache 2 Slack Status

LoggerAPI

A logger protocol that provides a common logging interface for different kinds of loggers. In addition, a class with a set of static functions for logging within your code is provided.

Kitura uses this API throughout its implementation when logging.

Prerequisites

Swift

  • Swift Open Source swift-5.1-RELEASE toolchain (Minimum REQUIRED for latest release)
  • Swift Open Source swift-5.4-RELEASE toolchain (Recommended)
  • Swift toolchain included in Xcode Version 11.0 or higher.

Usage

Add dependencies

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

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

Add LoggerAPI to your target's dependencies:

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

Import package

import LoggerAPI

Log messages

Add log messages to your application:

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

Define a logger

You need to define a logger in order to output these messages. You may wish to write your own Logger implementation, or you can use HeliumLogger that writes to standard output:

import LoggerAPI
import HeliumLogger

let myLogger = HeliumLogger(.info)
Log.logger = myLogger

You can find out more about HeliumLogger here.

Logging messages to swift-log

You can direct your log messages to be logged via swift-log by setting the swiftLogger property:

import LoggerAPI
import Logging

let myLogger = Logging.Logger(label: "myLogger")
myLogger.logLevel = .notice
Log.swiftLogger = myLogger

If both logger and swiftLogger are set, then log messages will be sent to both logging backends. The log level configured for a LoggerAPI Logger and a swift-log Logger are independent, so may be used to log at different levels.

Note that because the hierarchy of log levels defined by LoggerAPI and swift-log is slightly different, a mapping is defined between the levels. See the documentation for Log.isLogging() for details.

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.

loggerapiz's People

Contributors

djones6 avatar shmuelk avatar dannys42 avatar helenmasters avatar dfirsht avatar ianpartridge avatar shihabmehboob avatar andrew-lees11 avatar matteocrippa avatar rolivieri avatar youming-lin avatar rfdickerson avatar quanvo87 avatar mbarnach avatar kyemaloy97 avatar swiftdevops avatar mre-fog avatar tkhuran avatar vadimeisenbergibm avatar kilnerm avatar rob-deans avatar

Watchers

 avatar  avatar

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.