GithubHelp home page GithubHelp logo

isabella232 / perfect-requestlogger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from perfectlysoft/perfect-requestlogger

0.0 0.0 0.0 36 KB

SPM module for request logging filters for the Perfect framework for server-side Swift

Home Page: https://github.com/PerfectExamples/Perfect-HTTPRequestLogging

License: Apache License 2.0

Swift 100.00%

perfect-requestlogger's Introduction

Perfect HTTP Request Logging 简体中文

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 3.0 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

Swift Package Manager (SPM) module which provides HTTP request logging filters for use with the Perfect framework for server-side Swift.

Example Log Output

[INFO] [62f940aa-f204-43ed-9934-166896eda21c] [servername/WuAyNIIU-1] 2016-10-07 21:49:04 +0000 "GET /one HTTP/1.1" from 127.0.0.1 - 200 64B in 0.000436007976531982s
[INFO] [ec6a9ca5-00b1-4656-9e4c-ddecae8dde02] [servername/WuAyNIIU-2] 2016-10-07 21:49:06 +0000 "GET /two HTTP/1.1" from 127.0.0.1 - 200 64B in 0.000207006931304932s

Usage

Add the following dependency to the Package.swift file:

.Package(url: "https://github.com/PerfectlySoft/Perfect-RequestLogger.git", majorVersion: 0)

For each file you wish to directly reference the logging, import the module:

import PerfectRequestLogger

Add to main.swift after instantiating your server:

// Instantiate a logger
let myLogger = RequestLogger()

// Add the filters
// Request filter at high priority to be executed first
server.setRequestFilters([(myLogger, .high)])
// Response filter at low priority to be executed last
server.setResponseFilters([(myLogger, .low)])

These request & response filters add the required hooks to mark the beginning and the completion of the HTTP request and response.

Setting a custom Logfile location

The default logfile location is /var/log/perfectLog.log. To set a custom logfile location, set the RequestLogFile.location property:

RequestLogFile.location = "/var/log/myLog.log"

Further Information

For more information on the Perfect project, please visit perfect.org.

perfect-requestlogger's People

Contributors

iamjono avatar dabfleming avatar kjessup avatar rockfordwei avatar saroar 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.