Code Monkey home page Code Monkey logo

go-cloudwatchlogs's Introduction

Go package: go-cloudwatchlogs/awslogs

Before using the 'awslogs' package function please export the environment variable AWS_SDK_LOAD_CONFIG=1 or go to get more details and alternative configurations on https://github.com/aws/aws-sdk-go: "The SDK has support for the shared configuration file (~/.aws/config). This support can be enabled by setting the environment variable, "AWS_SDK_LOAD_CONFIG=1", or enabling the feature in code when creating a Session via the Option's SharedConfigState parameter."

The awslogs go package provides a function that you can use to post log messages (or any other string of interest) to AWS Cloudwatch.

The Go function LogToCloudwatch receives 2 arguments:

  • A string with the Cloudwatch log group name.
  • A string with the message to be logged into Cloudwatch. The function checks if the log group name/log stream name already exists and if not it creates the log group.

Usage example:

 import (
    "github.com/bamaralf/go-cloudwatchlogs/awslogs"
 ) 
 ...
 LogToCloudwatch ("test-group", "test message")
 ...

Usage example 2:

 import (
     "github.com/bamaralf/go-cloudwatchlogs/awslogs"
 )
 ...
 test := "test-group"
 LogToCloudwatch(test, "Cambio! This message will be logged on AWS Cloudwatch!")
 ...

The log group name will be the value kept on the logGroupName variable with a "." added to the beginning of the string.

".test-group"

The log stream inside the log group will be the hostname.

Dependencies:

AWS SDK for the Go programming language. http://aws.amazon.com/sdk-for-go/

brunoamaralf

go-cloudwatchlogs's People

Contributors

bamaralf avatar

Watchers

James Cloos 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.