Giter VIP home page Giter VIP logo

googlecloudlogging's Introduction

Hi there ๐Ÿ‘‹

googlecloudlogging's People

Contributors

dnv1ex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

googlecloudlogging's Issues

Support Linux Build

Currently, this project doesn't build on Linux. Using version 1.1.1:

$ which swift
/home/xander/swift-tensorflow-RELEASE-0.10-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM 55d27a5828, Swift 6a5d84ec08)
Target: x86_64-unknown-linux-gnu
$ swift build
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:32:29: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        case noDataReceived(URLResponse?)
                            ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:40:29: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        case noDataReceived(URLResponse?)
                            ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:216:18: error: 'URLSession' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
    let session: URLSession
                 ^~~~~~~~~~
Foundation.URLSession:2:18: note: 'URLSession' has been explicitly marked unavailable here
public typealias URLSession = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:132:34: error: cannot find type 'CFError' in scope
            var error: Unmanaged<CFError>?
                                 ^~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:31: error: cannot find 'kSecAttrKeyType' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                              ^~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:48: error: cannot find 'kSecAttrKeyTypeRSA' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                               ^~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:68: error: cannot find 'kSecAttrKeyClass' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                                                   ^~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:86: error: cannot find 'kSecAttrKeyClassPrivate' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:111: error: cannot find 'kSecAttrKeySizeInBits' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                                                                                              ^~~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:134:36: error: cannot find 'SecKeyCreateWithData' in scope
            guard let privateKey = SecKeyCreateWithData(key as CFData, attributes, &error) else {
                                   ^~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:137:35: error: cannot find 'SecKeyCreateSignature' in scope
            guard let signature = SecKeyCreateSignature(privateKey, .rsaSignatureMessagePKCS1v15SHA256, data as CFData, &error) as Data? else {
                                  ^~~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:229:19: error: 'URLSession' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        session = URLSession(configuration: .ephemeral, delegate: nil, delegateQueue: operationQueue)
                  ^~~~~~~~~~
Foundation.URLSession:2:18: note: 'URLSession' has been explicitly marked unavailable here
public typealias URLSession = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:240:27: error: cannot find 'URLRequest' in scope
            var request = URLRequest(url: url)
                          ^~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:305:27: error: cannot find 'URLRequest' in scope
            var request = URLRequest(url: url)
                          ^~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:387:29: error: cannot find 'applyingTransform' in scope
        let logId = String((applyingTransform(.toLatin, reverse: false) ?? self)
                            ^~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:40:29: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        case noDataReceived(URLResponse?)
                            ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^

Some of these errors could be resolved simply by changing import Foundation to:

import Foundation
#if canImport(FoundationNetworking)
    import FoundationNetworking
#endif

It looks like the authentication portions of it would need to be replaced by either CryptoSwift or google-auth-library-swift, both of which support Linux. The latter is Google's official library for authenticating with Google Cloud and may readily replace this functionality.

Log size handling

The log size handling is wrong .. it is based on the number of lines before being encoded.

I see some logs not being uploaded and a log of errors like:

error=errorReceived(GoogleCloudLogging.GoogleCloudLogging.Response.Error(code: 400, message: "Request payload size exceeds the limit: 10485760 bytes.", status: "INVALID_ARGUMENT")) [GoogleCloudLogging] Unable to upload 
excludedLogEntryCount=4 maxLogSize=10000000 [GoogleCloudLogging] Some log entries are excluded from the upload due to exceeding the log size limit

How to change Label in logs?

This is a typical out of the box log from the library:

2021-06-12T12:03:48-0400 info GoogleCloudLogHandler : Logs have been uploaded

How do i change the label "GoogleCloudLogHandler" so that it does not show in the Google Cloud Logging console,
it reflects something another label?

Thanks for the library!

How do I upload logs immediately?

In your introduction you state that logs can be uploaded in response to a given event. How do we customise this? As I am developing the app, I would like immediate upload to the backend. Currently I have the following, which works, but this obviously then removes the usefulness of the source error information that is uploaded and I suspect isn't the proper way to do it.

class CustomLogging {
    static var shared = CustomLogging()
    
    public func info(message: String) {
        logger.info("\(message)")
        GoogleCloudLogHandler.upload()        
    }
}

let Log = CustomLogging.shared

//somewhere else
Log.info(message:"whatever")

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.