dnv1ex / googlecloudlogging Goto Github PK
View Code? Open in Web Editor NEWSwift (Darwin) library for logging application events in Google Cloud.
License: Apache License 2.0
Swift (Darwin) library for logging application events in Google Cloud.
License: Apache License 2.0
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.
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
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!
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")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.