Simple Swift Logging Library (require: Swift-Logger-Server)
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Sources/SwiftLoggerClient
Tests
.gitattributes
.gitignore
LICENSE
Package.resolved
Package.swift
README.md

README.md

macOS iOS Linux license

Swift Logger Client

Swift Logger Class for Usage With Swift Logger Server Application

Simple Logger class used for sending Debug, Info, Warning and Error log messages to the logger API.

Prerequisites

Swift

  • Open Source Swift 4.0.0 or higher

macOS

  • macOS Sierra 10.12.6 or higher
  • Xcode Version 9.0 (9A325) or higher

iOS

  • iOS 10.0 or higher

Linux

  • Ubuntu 16.04 & 16.10 (only tested on 16.04)

Getting started

import SwiftLoggerClient

API

Public variables & default values

The following public variables should be set to your desired values.

public let SWIFT_LOGGER_backEndSchema = "http"
public let SWIFT_LOGGER_backEndPort: Int16 = 80

Logger class initialization

let log = Logger(applicationName: String, target: Target, onServer: String, state: State)

Target enum

public enum Target {
    case file
    case terminal
}

State enum

public enum State {
    case enabled
    case disabled
}

Exampe usage with viable data:

let log = Logger(applicationName: "MyApplication", target: .file, onServer: "logging.craftwell.io", state: .enabled)

log.debug(message: "This is a debug message.")
log.info(message: "This is an info message.")
log.warning(message: "This is a warning message.")
log.error(message: "An error has occurred.")

// Event can also be logged without passing message parameter:
log.debug()
log.info()
log.warning()
log.error()

More information about server API configuration is to be found on: Logging Events Using Swift Cloud Logger

License

MIT Licence