How to use log method of is Package

Best Is code snippet using is.log

logs.go

Source:logs.go Github

copy

Full Screen

1// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.2// Package logs provides a client for Amazon CloudWatch Logs.3package logs4import (5 "net/http"6 "time"7 "github.com/awslabs/aws-sdk-go/aws"8 "github.com/awslabs/aws-sdk-go/gen/endpoints"9)10// Logs is a client for Amazon CloudWatch Logs.11type Logs struct {12 client *aws.JSONClient13}14// New returns a new Logs client.15func New(creds aws.CredentialsProvider, region string, client *http.Client) *Logs {16 if client == nil {17 client = http.DefaultClient18 }19 endpoint, service, region := endpoints.Lookup("logs", region)20 return &Logs{21 client: &aws.JSONClient{22 Context: aws.Context{23 Credentials: creds,24 Service: service,25 Region: region,26 }, Client: client,27 Endpoint: endpoint,28 JSONVersion: "1.1",29 TargetPrefix: "Logs_20140328",30 },31 }32}33// CreateLogGroup creates a new log group with the specified name. The name34// of the log group must be unique within a region for an AWS account. You35// can create up to 500 log groups per account. You must use the following36// guidelines when naming a log group: Log group names can be between 1 and37// 512 characters long. Allowed characters are a-z, 0-9, '_' (underscore),38// '-' (hyphen), '/' (forward slash), and '.' (period).39func (c *Logs) CreateLogGroup(req *CreateLogGroupRequest) (err error) {40 // NRE41 err = c.client.Do("CreateLogGroup", "POST", "/", req, nil)42 return43}44// CreateLogStream creates a new log stream in the specified log group. The45// name of the log stream must be unique within the log group. There is no46// limit on the number of log streams that can exist in a log group. You47// must use the following guidelines when naming a log stream: Log stream48// names can be between 1 and 512 characters long. The ':' colon character49// is not allowed.50func (c *Logs) CreateLogStream(req *CreateLogStreamRequest) (err error) {51 // NRE52 err = c.client.Do("CreateLogStream", "POST", "/", req, nil)53 return54}55// DeleteLogGroup deletes the log group with the specified name and56// permanently deletes all the archived log events associated with it.57func (c *Logs) DeleteLogGroup(req *DeleteLogGroupRequest) (err error) {58 // NRE59 err = c.client.Do("DeleteLogGroup", "POST", "/", req, nil)60 return61}62// DeleteLogStream deletes a log stream and permanently deletes all the63// archived log events associated with it.64func (c *Logs) DeleteLogStream(req *DeleteLogStreamRequest) (err error) {65 // NRE66 err = c.client.Do("DeleteLogStream", "POST", "/", req, nil)67 return68}69// DeleteMetricFilter deletes a metric filter associated with the specified70// log group.71func (c *Logs) DeleteMetricFilter(req *DeleteMetricFilterRequest) (err error) {72 // NRE73 err = c.client.Do("DeleteMetricFilter", "POST", "/", req, nil)74 return75}76// DeleteRetentionPolicy deletes the retention policy of the specified log77// group. Log events would not expire if they belong to log groups without78// a retention policy.79func (c *Logs) DeleteRetentionPolicy(req *DeleteRetentionPolicyRequest) (err error) {80 // NRE81 err = c.client.Do("DeleteRetentionPolicy", "POST", "/", req, nil)82 return83}84// DescribeLogGroups returns all the log groups that are associated with85// the AWS account making the request. The list returned in the response is86// ASCII-sorted by log group name. By default, this operation returns up to87// 50 log groups. If there are more log groups to list, the response would88// contain a nextToken value in the response body. You can also limit the89// number of log groups returned in the response by specifying the limit90// parameter in the request.91func (c *Logs) DescribeLogGroups(req *DescribeLogGroupsRequest) (resp *DescribeLogGroupsResponse, err error) {92 resp = &DescribeLogGroupsResponse{}93 err = c.client.Do("DescribeLogGroups", "POST", "/", req, resp)94 return95}96// DescribeLogStreams returns all the log streams that are associated with97// the specified log group. The list returned in the response is98// ASCII-sorted by log stream name. By default, this operation returns up99// to 50 log streams. If there are more log streams to list, the response100// would contain a nextToken value in the response body. You can also limit101// the number of log streams returned in the response by specifying the102// limit parameter in the request.103func (c *Logs) DescribeLogStreams(req *DescribeLogStreamsRequest) (resp *DescribeLogStreamsResponse, err error) {104 resp = &DescribeLogStreamsResponse{}105 err = c.client.Do("DescribeLogStreams", "POST", "/", req, resp)106 return107}108// DescribeMetricFilters returns all the metrics filters associated with109// the specified log group. The list returned in the response is110// ASCII-sorted by filter name. By default, this operation returns up to 50111// metric filters. If there are more metric filters to list, the response112// would contain a nextToken value in the response body. You can also limit113// the number of metric filters returned in the response by specifying the114// limit parameter in the request.115func (c *Logs) DescribeMetricFilters(req *DescribeMetricFiltersRequest) (resp *DescribeMetricFiltersResponse, err error) {116 resp = &DescribeMetricFiltersResponse{}117 err = c.client.Do("DescribeMetricFilters", "POST", "/", req, resp)118 return119}120// GetLogEvents retrieves log events from the specified log stream. You can121// provide an optional time range to filter the results on the event122// timestamp . By default, this operation returns as much log events as can123// fit in a response size of 1MB, up to 10,000 log events. The response124// will always include a nextForwardToken and a nextBackwardToken in the125// response body. You can use any of these tokens in subsequent126// GetLogEvents requests to paginate through events in either forward or127// backward direction. You can also limit the number of log events returned128// in the response by specifying the limit parameter in the request.129func (c *Logs) GetLogEvents(req *GetLogEventsRequest) (resp *GetLogEventsResponse, err error) {130 resp = &GetLogEventsResponse{}131 err = c.client.Do("GetLogEvents", "POST", "/", req, resp)132 return133}134// PutLogEvents uploads a batch of log events to the specified log stream.135// Every PutLogEvents request must include the sequenceToken obtained from136// the response of the previous request. An upload in a newly created log137// stream does not require a sequenceToken . The batch of events must138// satisfy the following constraints: The maximum batch size is 32,768139// bytes, and this size is calculated as the sum of all event messages in140// UTF-8, plus 26 bytes for each log event. None of the log events in the141// batch can be more than 2 hours in the future. None of the log events in142// the batch can be older than 14 days or the retention period of the log143// group. The log events in the batch must be in chronological ordered by144// their timestamp The maximum number of log events in a batch is 1,000.145func (c *Logs) PutLogEvents(req *PutLogEventsRequest) (resp *PutLogEventsResponse, err error) {146 resp = &PutLogEventsResponse{}147 err = c.client.Do("PutLogEvents", "POST", "/", req, resp)148 return149}150// PutMetricFilter creates or updates a metric filter and associates it151// with the specified log group. Metric filters allow you to configure152// rules to extract metric data from log events ingested through153// PutLogEvents requests.154func (c *Logs) PutMetricFilter(req *PutMetricFilterRequest) (err error) {155 // NRE156 err = c.client.Do("PutMetricFilter", "POST", "/", req, nil)157 return158}159// PutRetentionPolicy sets the retention of the specified log group. A160// retention policy allows you to configure the number of days you want to161// retain log events in the specified log group.162func (c *Logs) PutRetentionPolicy(req *PutRetentionPolicyRequest) (err error) {163 // NRE164 err = c.client.Do("PutRetentionPolicy", "POST", "/", req, nil)165 return166}167// TestMetricFilter tests the filter pattern of a metric filter against a168// sample of log event messages. You can use this operation to validate the169// correctness of a metric filter pattern.170func (c *Logs) TestMetricFilter(req *TestMetricFilterRequest) (resp *TestMetricFilterResponse, err error) {171 resp = &TestMetricFilterResponse{}172 err = c.client.Do("TestMetricFilter", "POST", "/", req, resp)173 return174}175// CreateLogGroupRequest is undocumented.176type CreateLogGroupRequest struct {177 LogGroupName aws.StringValue `json:"logGroupName"`178}179// CreateLogStreamRequest is undocumented.180type CreateLogStreamRequest struct {181 LogGroupName aws.StringValue `json:"logGroupName"`182 LogStreamName aws.StringValue `json:"logStreamName"`183}184// DeleteLogGroupRequest is undocumented.185type DeleteLogGroupRequest struct {186 LogGroupName aws.StringValue `json:"logGroupName"`187}188// DeleteLogStreamRequest is undocumented.189type DeleteLogStreamRequest struct {190 LogGroupName aws.StringValue `json:"logGroupName"`191 LogStreamName aws.StringValue `json:"logStreamName"`192}193// DeleteMetricFilterRequest is undocumented.194type DeleteMetricFilterRequest struct {195 FilterName aws.StringValue `json:"filterName"`196 LogGroupName aws.StringValue `json:"logGroupName"`197}198// DeleteRetentionPolicyRequest is undocumented.199type DeleteRetentionPolicyRequest struct {200 LogGroupName aws.StringValue `json:"logGroupName"`201}202// DescribeLogGroupsRequest is undocumented.203type DescribeLogGroupsRequest struct {204 Limit aws.IntegerValue `json:"limit,omitempty"`205 LogGroupNamePrefix aws.StringValue `json:"logGroupNamePrefix,omitempty"`206 NextToken aws.StringValue `json:"nextToken,omitempty"`207}208// DescribeLogGroupsResponse is undocumented.209type DescribeLogGroupsResponse struct {210 LogGroups []LogGroup `json:"logGroups,omitempty"`211 NextToken aws.StringValue `json:"nextToken,omitempty"`212}213// DescribeLogStreamsRequest is undocumented.214type DescribeLogStreamsRequest struct {215 Limit aws.IntegerValue `json:"limit,omitempty"`216 LogGroupName aws.StringValue `json:"logGroupName"`217 LogStreamNamePrefix aws.StringValue `json:"logStreamNamePrefix,omitempty"`218 NextToken aws.StringValue `json:"nextToken,omitempty"`219}220// DescribeLogStreamsResponse is undocumented.221type DescribeLogStreamsResponse struct {222 LogStreams []LogStream `json:"logStreams,omitempty"`223 NextToken aws.StringValue `json:"nextToken,omitempty"`224}225// DescribeMetricFiltersRequest is undocumented.226type DescribeMetricFiltersRequest struct {227 FilterNamePrefix aws.StringValue `json:"filterNamePrefix,omitempty"`228 Limit aws.IntegerValue `json:"limit,omitempty"`229 LogGroupName aws.StringValue `json:"logGroupName"`230 NextToken aws.StringValue `json:"nextToken,omitempty"`231}232// DescribeMetricFiltersResponse is undocumented.233type DescribeMetricFiltersResponse struct {234 MetricFilters []MetricFilter `json:"metricFilters,omitempty"`235 NextToken aws.StringValue `json:"nextToken,omitempty"`236}237// GetLogEventsRequest is undocumented.238type GetLogEventsRequest struct {239 EndTime aws.LongValue `json:"endTime,omitempty"`240 Limit aws.IntegerValue `json:"limit,omitempty"`241 LogGroupName aws.StringValue `json:"logGroupName"`242 LogStreamName aws.StringValue `json:"logStreamName"`243 NextToken aws.StringValue `json:"nextToken,omitempty"`244 StartFromHead aws.BooleanValue `json:"startFromHead,omitempty"`245 StartTime aws.LongValue `json:"startTime,omitempty"`246}247// GetLogEventsResponse is undocumented.248type GetLogEventsResponse struct {249 Events []OutputLogEvent `json:"events,omitempty"`250 NextBackwardToken aws.StringValue `json:"nextBackwardToken,omitempty"`251 NextForwardToken aws.StringValue `json:"nextForwardToken,omitempty"`252}253// InputLogEvent is undocumented.254type InputLogEvent struct {255 Message aws.StringValue `json:"message"`256 Timestamp aws.LongValue `json:"timestamp"`257}258// LogGroup is undocumented.259type LogGroup struct {260 ARN aws.StringValue `json:"arn,omitempty"`261 CreationTime aws.LongValue `json:"creationTime,omitempty"`262 LogGroupName aws.StringValue `json:"logGroupName,omitempty"`263 MetricFilterCount aws.IntegerValue `json:"metricFilterCount,omitempty"`264 RetentionInDays aws.IntegerValue `json:"retentionInDays,omitempty"`265 StoredBytes aws.LongValue `json:"storedBytes,omitempty"`266}267// LogStream is undocumented.268type LogStream struct {269 ARN aws.StringValue `json:"arn,omitempty"`270 CreationTime aws.LongValue `json:"creationTime,omitempty"`271 FirstEventTimestamp aws.LongValue `json:"firstEventTimestamp,omitempty"`272 LastEventTimestamp aws.LongValue `json:"lastEventTimestamp,omitempty"`273 LastIngestionTime aws.LongValue `json:"lastIngestionTime,omitempty"`274 LogStreamName aws.StringValue `json:"logStreamName,omitempty"`275 StoredBytes aws.LongValue `json:"storedBytes,omitempty"`276 UploadSequenceToken aws.StringValue `json:"uploadSequenceToken,omitempty"`277}278// MetricFilter is undocumented.279type MetricFilter struct {280 CreationTime aws.LongValue `json:"creationTime,omitempty"`281 FilterName aws.StringValue `json:"filterName,omitempty"`282 FilterPattern aws.StringValue `json:"filterPattern,omitempty"`283 MetricTransformations []MetricTransformation `json:"metricTransformations,omitempty"`284}285// MetricFilterMatchRecord is undocumented.286type MetricFilterMatchRecord struct {287 EventMessage aws.StringValue `json:"eventMessage,omitempty"`288 EventNumber aws.LongValue `json:"eventNumber,omitempty"`289 ExtractedValues map[string]string `json:"extractedValues,omitempty"`290}291// MetricTransformation is undocumented.292type MetricTransformation struct {293 MetricName aws.StringValue `json:"metricName"`294 MetricNamespace aws.StringValue `json:"metricNamespace"`295 MetricValue aws.StringValue `json:"metricValue"`296}297// OutputLogEvent is undocumented.298type OutputLogEvent struct {299 IngestionTime aws.LongValue `json:"ingestionTime,omitempty"`300 Message aws.StringValue `json:"message,omitempty"`301 Timestamp aws.LongValue `json:"timestamp,omitempty"`302}303// PutLogEventsRequest is undocumented.304type PutLogEventsRequest struct {305 LogEvents []InputLogEvent `json:"logEvents"`306 LogGroupName aws.StringValue `json:"logGroupName"`307 LogStreamName aws.StringValue `json:"logStreamName"`308 SequenceToken aws.StringValue `json:"sequenceToken,omitempty"`309}310// PutLogEventsResponse is undocumented.311type PutLogEventsResponse struct {312 NextSequenceToken aws.StringValue `json:"nextSequenceToken,omitempty"`313}314// PutMetricFilterRequest is undocumented.315type PutMetricFilterRequest struct {316 FilterName aws.StringValue `json:"filterName"`317 FilterPattern aws.StringValue `json:"filterPattern"`318 LogGroupName aws.StringValue `json:"logGroupName"`319 MetricTransformations []MetricTransformation `json:"metricTransformations"`320}321// PutRetentionPolicyRequest is undocumented.322type PutRetentionPolicyRequest struct {323 LogGroupName aws.StringValue `json:"logGroupName"`324 RetentionInDays aws.IntegerValue `json:"retentionInDays"`325}326// TestMetricFilterRequest is undocumented.327type TestMetricFilterRequest struct {328 FilterPattern aws.StringValue `json:"filterPattern"`329 LogEventMessages []string `json:"logEventMessages"`330}331// TestMetricFilterResponse is undocumented.332type TestMetricFilterResponse struct {333 Matches []MetricFilterMatchRecord `json:"matches,omitempty"`334}335// avoid errors if the packages aren't referenced336var _ time.Time...

Full Screen

Full Screen

constants.go

Source:constants.go Github

copy

Full Screen

...12limitations under the License.13*/14package nvdimm15import (16 log "github.com/Sirupsen/logrus"17)18// #cgo LDFLAGS: -L/lib64 -lixpdimm19// #include <nvm_management.h>20// #include <nvm_types.h>21import "C"22//go:generate stringer -type=EncryptionString23//go:generate stringer -type=PoolHealthString24//go:generate stringer -type=InterleaveSetHealth25//go:generate stringer -type=TypeNamespace26//go:generate stringer -type=HealthNamespace27//go:generate stringer -type=StateNamespace28type EncryptionString int29type PoolHealthString int30type InterleaveSetHealth int31type TypeNamespace int32type HealthNamespace int33type StateNamespace int34const (35 NVM_ENCRYPTION_OFF EncryptionString = 036 NVM_ENCRYPTION_ON EncryptionString = 137 NVM_ENCRYPTION_IGNORE EncryptionString = 238 UNKNOWN PoolHealthString = 0 // The pool health cannot be determined.39 NORMAL PoolHealthString = 1 // All underlying AEP DIMM Persistent memory capacity is available.40 PENDING PoolHealthString = 2 // A new memory allocation goal has been created but not applied.41 ERROR PoolHealthString = 3 // There is an issue with some or all of the underlying42 LOCKED PoolHealthString = 4 // One or more of the underlying AEP DIMMs are locked.43 HEALTH_UNKNOWN InterleaveSetHealth = 044 HEALTH_NORMAL InterleaveSetHealth = 1 // Available and underlying AEP DIMMs have good health.45 DEGRADED InterleaveSetHealth = 2 // In danger of failure, may have degraded performance.46 FAILED InterleaveSetHealth = 3 // Interleave set has failed and is unavailable.47 TYPE_UNKNOWN TypeNamespace = 0 // Type cannot be determined48 TYPE_STORAGE TypeNamespace = 1 // Storage namespace49 TYPE_APP_DIRECT TypeNamespace = 2 // App Direct namespace50 NAMESPACE_HEALTH_UNKNOWN HealthNamespace = 0 // Namespace health cannot be determined51 NAMESPACE_HEALTH_NORMAL HealthNamespace = 5 // Namespace is OK52 NAMESPACE_HEALTH_NONCRITICAL HealthNamespace = 10 // Non-critical health issue53 NAMESPACE_HEALTH_CRITICAL HealthNamespace = 25 // Critical health issue54 NAMESPACE_HEALTH_BROKENMIRROR HealthNamespace = 65535 // Broken mirror55 STATE_UNKNOWN StateNamespace = 0 // Cannot be determined56 STATE_ENABLED StateNamespace = 2 // Exposed to OS57 STATE_DISABLED StateNamespace = 3 // Hidden from OS58)59func logError(code int) {60 switch code {61 case C.NVM_ERR_INVALIDPERMISSIONS:62 log.Error("Invalid permissions")63 case C.NVM_ERR_NOTSUPPORTED:64 log.Error("This method is not supported in the current context")65 case C.NVM_ERR_NOMEMORY:66 log.Error("Not enough memory to complete the requested operation")67 case C.NVM_ERR_UNKNOWN:68 log.Error("An unknown error occurred")69 case C.NVM_ERR_NOSIMULATOR:70 log.Error("No simulator is loaded")71 case C.NVM_ERR_BADDRIVER:72 log.Error("The underlying software is missing or incompatible")73 case C.NVM_ERR_NOTMANAGEABLE:74 log.Error("The device is not manageable by the management software")75 case C.NVM_ERR_DATATRANSFERERROR:76 log.Error("There was an error in the data transfer")77 case C.NVM_SUCCESS:78 log.Debug("Success")79 case C.NVM_ERR_BADERRORCODE:80 log.Error("The return code was not valid")81 case C.NVM_ERR_DEVICEERROR:82 log.Error("There was an internal error in the device")83 case C.NVM_ERR_DEVICEBUSY:84 log.Error("The device is currently busy processing a long operation command")85 case C.NVM_ERR_BADPASSPHRASE:86 log.Error("The passphrase is not valid")87 case C.NVM_ERR_INVALIDPASSPHRASE:88 log.Error("The new passphrase does not meet the minimum requirements")89 case C.NVM_ERR_SECURITYFROZEN:90 log.Error("No changes can be made to the security state of the device")91 case C.NVM_ERR_LIMITPASSPHRASE:92 log.Error("The maximum passphrase submission limit has been reached")93 case C.NVM_ERR_SECURITYDISABLED:94 log.Error("Data at rest security is not enabled")95 case C.NVM_ERR_BADDEVICE:96 log.Error("The device identifier is not valid")97 case C.NVM_ERR_ARRAYTOOSMALL:98 log.Error("The array is not big enough")99 case C.NVM_ERR_BADCALLBACK:100 log.Error("The callback identifier is not valid")101 case C.NVM_ERR_BADFILE:102 log.Error("The file is not valid")103 case C.NVM_ERR_BADPOOL:104 log.Error("The pool identifier is not valid")105 case C.NVM_ERR_BADNAMESPACE:106 log.Error("The namespace identifier is not valid")107 case C.NVM_ERR_BADBLOCKSIZE:108 log.Error("The specified block size is not valid")109 case C.NVM_ERR_BADSIZE:110 log.Error("The size specified is not valid")111 case C.NVM_ERR_BADFIRMWARE:112 log.Error("The firmware image is not valid for the device")113 case C.NVM_ERR_DRIVERFAILED:114 log.Error("The device driver failed the requested operation")115 case C.NVM_ERR_BADSOCKET:116 log.Error("The processor socket identifier is not valid")117 case C.NVM_ERR_BADSECURITYSTATE:118 log.Error("Device security state does not permit the request")119 case C.NVM_ERR_REQUIRESFORCE:120 log.Error("This method requires the force flag to proceed")121 case C.NVM_ERR_NAMESPACESEXIST:122 log.Error("Existing namespaces must be deleted first")123 case C.NVM_ERR_NOTFOUND:124 log.Error("The requested item was not found")125 case C.NVM_ERR_BADDEVICECONFIG:126 log.Error("The configuration data is invalid or unrecognized.")127 case C.NVM_ERR_DRIVERNOTALLOWED:128 log.Error("Driver is not allowing this command")129 case C.NVM_ERR_BADALIGNMENT:130 log.Error("The specified size does not have the required alignment")131 case C.NVM_ERR_BADTHRESHOLD:132 log.Error("The threshold value is invalid.")133 case C.NVM_ERR_EXCEEDSMAXSUBSCRIBERS:134 log.Error("Exceeded maximum number of notify subscribers")135 case C.NVM_ERR_BADNAMESPACETYPE:136 log.Error("The specified namespace type is not valid")137 case C.NVM_ERR_BADNAMESPACEENABLESTATE:138 log.Error("The specified namespace enable state is not valid")139 case C.NVM_ERR_BADNAMESPACESETTINGS:140 log.Error("Could not create ns with specified settings")141 case C.NVM_ERR_BADPCAT:142 log.Error("The PCAT table is invalid")143 case C.NVM_ERR_TOOMANYNAMESPACES:144 log.Error("The maximum number of namespaces is already present")145 case C.NVM_ERR_CONFIGNOTSUPPORTED:146 log.Error("The requested configuration is not supported")147 case C.NVM_ERR_SKUVIOLATION:148 log.Error("The method is not supported because of a license violation")149 case C.NVM_ERR_ARSINPROGRESS:150 log.Error("Address range scrub in progress")151 case C.NVM_ERR_BADSECURITYGOAL:152 log.Error("No dimm found with matching security goal to create a NS")153 case C.NVM_ERR_INVALIDPASSPHRASEFILE:154 log.Error("The passphrase file is invalid")155 case C.NVM_ERR_GOALPENDING:156 log.Error("Memory allocation goal is pending reboot")157 case C.NVM_ERR_BADPOOLHEALTH:158 log.Error("Underlying persistent memory is unavailable")159 case C.NVM_ERR_INVALIDMEMORYTYPE:160 log.Error("The address does not match the specified memory type")161 case C.NVM_ERR_INCOMPATIBLEFW:162 log.Error("The firmware image is not compatible with this version of software")163 case C.NVM_ERR_NAMESPACEBUSY:164 log.Error("The namespace cannot be changed because it is in use by a file system")165 case C.NVM_ERR_FWALREADYSTAGED:166 log.Error("A firmware image is already staged for execution. A power cycle is required before another can be staged.")167 case C.NVM_ERR_BADNFIT:168 log.Error("The NFIT table is invalid")169 default:170 log.Error("Unrecognized error code. Please notify us.")171 }172}173func convertSensorUnits(unit int) string {174 var unit_name string175 switch unit {176 case 1: // UNIT_COUNT177 unit_name = ""178 case 2: // UNIT_CELSIUS179 unit_name = "C"180 case 21: // UNIT_SECONDS181 unit_name = "s"182 case 22: // UNIT_MINUTES183 unit_name = "m"184 case 23: // UNIT_HOURS...

Full Screen

Full Screen

shim_test.go

Source:shim_test.go Github

copy

Full Screen

...13package shim14import (15 "os"16 "testing"17 "github.com/op/go-logging"18)19// Test Go shim functionality that can be tested outside of a real chaincode20// context.21// TestShimLogging simply tests that the APIs are working. These tests test22// for correct control over the shim's logging object and the LogLevel23// function.24func TestShimLogging(t *testing.T) {25 SetLoggingLevel(LogCritical)26 if shimLoggingLevel != LogCritical {27 t.Errorf("shimLoggingLevel is not LogCritical as expected")28 }29 if chaincodeLogger.IsEnabledFor(logging.DEBUG) {30 t.Errorf("The chaincodeLogger should not be enabled for DEBUG")31 }32 if !chaincodeLogger.IsEnabledFor(logging.CRITICAL) {33 t.Errorf("The chaincodeLogger should be enabled for CRITICAL")34 }35 var level LoggingLevel36 var err error37 level, err = LogLevel("debug")38 if err != nil {39 t.Errorf("LogLevel(debug) failed")40 }41 if level != LogDebug {42 t.Errorf("LogLevel(debug) did not return LogDebug")43 }44 level, err = LogLevel("INFO")45 if err != nil {46 t.Errorf("LogLevel(INFO) failed")47 }48 if level != LogInfo {49 t.Errorf("LogLevel(INFO) did not return LogInfo")50 }51 level, err = LogLevel("Notice")52 if err != nil {53 t.Errorf("LogLevel(Notice) failed")54 }55 if level != LogNotice {56 t.Errorf("LogLevel(Notice) did not return LogNotice")57 }58 level, err = LogLevel("WaRnInG")59 if err != nil {60 t.Errorf("LogLevel(WaRnInG) failed")61 }62 if level != LogWarning {63 t.Errorf("LogLevel(WaRnInG) did not return LogWarning")64 }65 level, err = LogLevel("ERRor")66 if err != nil {67 t.Errorf("LogLevel(ERRor) failed")68 }69 if level != LogError {70 t.Errorf("LogLevel(ERRor) did not return LogError")71 }72 level, err = LogLevel("critiCAL")73 if err != nil {74 t.Errorf("LogLevel(critiCAL) failed")75 }76 if level != LogCritical {77 t.Errorf("LogLevel(critiCAL) did not return LogCritical")78 }79 level, err = LogLevel("foo")80 if err == nil {81 t.Errorf("LogLevel(foo) did not fail")82 }83 if level != LogError {84 t.Errorf("LogLevel(foo) did not return LogError")85 }86}87// TestChaincodeLogging tests the logging APIs for chaincodes.88func TestChaincodeLogging(t *testing.T) {89 // From start() - We can't call start() from this test90 format := logging.MustStringFormatter("%{time:15:04:05.000} [%{module}] %{level:.4s} : %{message}")91 backend := logging.NewLogBackend(os.Stderr, "", 0)92 backendFormatter := logging.NewBackendFormatter(backend, format)93 logging.SetBackend(backendFormatter).SetLevel(logging.Level(shimLoggingLevel), "shim")94 foo := NewLogger("foo")95 bar := NewLogger("bar")96 foo.Debugf("Foo is debugging: %d", 10)97 bar.Infof("Bar is informational? %s.", "Yes")98 foo.Noticef("NOTE NOTE NOTE")99 bar.Warningf("Danger, Danger %s %s", "Will", "Robinson!")100 foo.Errorf("I'm sorry Dave, I'm afraid I can't do that.")101 bar.Criticalf("PI is not equal to 3.14, we computed it as %.2f", 4.13)102 bar.Debug("Foo is debugging:", 10)103 foo.Info("Bar is informational?", "Yes.")104 bar.Notice("NOTE NOTE NOTE")105 foo.Warning("Danger, Danger", "Will", "Robinson!")106 bar.Error("I'm sorry Dave, I'm afraid I can't do that.")107 foo.Critical("PI is not equal to", 3.14, ", we computed it as", 4.13)...

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, World!")4}5import "fmt"6func main() {7 fmt.Println("Hello, World!")8}9import "fmt"10func main() {11 fmt.Println("Hello, World!")12}13import "fmt"14func main() {15 fmt.Println("Hello, World!")16}17import "fmt"18func main() {19 fmt.Println("Hello, World!")20}21import "fmt"22func main() {23 fmt.Println("Hello, World!")24}25import "fmt"26func main() {27 fmt.Println("Hello, World!")28}29import "fmt"30func main() {31 fmt.Println("Hello, World!")32}33import "fmt"34func main() {35 fmt.Println("Hello, World!")36}37import "fmt"38func main() {39 fmt.Println("Hello, World!")40}41import "fmt"42func main() {43 fmt.Println("Hello, World!")44}45import "fmt"46func main() {47 fmt.Println("Hello, World!")48}49import "fmt"50func main() {51 fmt.Println("Hello, World!")52}53import "fmt"54func main() {55 fmt.Println("Hello,

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import "github.com/astaxie/beego/logs"2func main() {3 logs.SetLogger("file", `{"filename":"test.log"}`)4 logs.SetLevel(logs.LevelDebug)5 logs.EnableFuncCallDepth(true)6 logs.Async(1e3)7 logs.Debug("this is a test, my name is %s", "astaxie")8 logs.Trace("this is a test, my name is %s", "astaxie")9 logs.Warn("this is a test, my name is %s", "astaxie")10 logs.Error(1024, "this is a test, my name is %s", "astaxie")11 logs.Critical("emergency! this is a test, my name is %s", "astaxie")12}13import "github.com/astaxie/beego/logs"14func main() {15 logs.SetLogger("file", `{"filename":"test.log"}`)16 logs.SetLevel(logs.LevelDebug)17 logs.EnableFuncCallDepth(true)18 logs.Async(1e3)19 logs.Debug("this is a test, my name is %s", "astaxie")20 logs.Trace("this is a test, my name is %s", "astaxie")21 logs.Warn("this is a test, my name is %s", "astaxie")22 logs.Error(1024, "this is a test, my name is %s", "astaxie")23 logs.Critical("emergency! this is a test, my name is %s", "astaxie")24}25import "github.com/astaxie/beego/logs"26func main() {27 logs.SetLogger("file", `{"filename":"test.log"}`)28 logs.SetLevel(logs.LevelDebug)29 logs.EnableFuncCallDepth(true)30 logs.Async(1e3)31 logs.Debug("this is a test, my name is %s", "astaxie")32 logs.Trace("this is a test, my name is %s", "astaxie")33 logs.Warn("this is a test, my name is %s", "astaxie")34 logs.Error(1024, "this is a test, my name is %s", "

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import "log"2func main() {3 log.Println("Hello World")4}5import (6func main() {7 log.Println("Hello World")8 fmt.Println(log.Prefix())9 log.SetPrefix("My Log: ")10 log.Println("Hello World")11 log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)12 log.Println("Hello World")13 log.SetOutput(os.Stdout)14 log.Println("Hello World")15}16import (17func main() {18 log.Println("Hello World")19 fmt.Println(log.Prefix())20 log.SetPrefix("My Log: ")21 log.Println("Hello World")22 log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)23 log.Println("Hello World")24 log.SetOutput(os.Stdout)25 log.Println("Hello World")26}27import (28func main() {29 log.Println("Hello World")30 fmt.Println(log.Prefix())31 log.SetPrefix("My Log: ")32 log.Println("Hello World")33 log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)34 log.Println("Hello World")35 log.SetOutput(os.Stdout)36 log.Println("Hello World")37}38import (39func main() {40 log.Println("Hello World")41 fmt.Println(log.Prefix())42 log.SetPrefix("My Log: ")43 log.Println("Hello World")44 log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)45 log.Println("Hello World")

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import "log"2func main() {3log.Println("Hello World")4}5import "log"6func main() {7log.Println("Hello World")8log.Printf("Hello %s", "World")9}10import "log"11func main() {12log.Println("Hello World")13log.Printf("Hello %s", "World")14log.Panic("Panic")15}16log.Panic(0xc00006bf78, 0x1, 0x1)17main.main()18log.Panic(0xc00006bf78, 0x1, 0x1)19main.main()20import "log"21func main() {22log.Println("Hello World")23log.Printf("Hello %s", "World")24log.Panic("Panic")25log.Fatal("Fatal")26}

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1func main() {2 is := initLogger()3 is.log("Hello world")4}5func main() {6 is := initLogger()7 is.log("Hello world")8}9import (10func main() {11 file, err := os.Open("test.txt")12 if err != nil {13 fmt.Println(err)14 }15 defer file.Close()16 scanner := bufio.NewScanner(file)17 scanner.Split(bufio.ScanWords)18 for scanner.Scan() {19 fmt.Println(scanner.Text())20 }21 if err := scanner.Err(); err != nil {22 fmt.Println(err)23 }24}

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 logs.Debug("this is a test, my name is %s", "slene")4 logs.Trace("this is a test, my name is %s", "slene")5 logs.Warn("this is a test, my name is %s", "slene")6 logs.Info("this is a test, my name is %s", "slene")7 logs.Error("this is a test, my name is %s", "slene")8 logs.Critical("this is a test, my name is %s", "slene")9 }10import (11func main() {12 logs.SetLogger(logs.AdapterFile, `{"filename":"test.log","level":7,"maxlines":0,"maxsize":

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4 log.Println("Hello World")5 pretty.Println("Hello World")6}7import (8func main() {9 fmt.Println("Hello World")10 log.Println("Hello World")11 pretty.Println("Hello World")12}13import (14func main() {15 fmt.Println("Hello World")16 log.Println("Hello World")17 pretty.Println("Hello World")18}19import (20func main() {21 fmt.Println("Hello World")22 log.Println("Hello World")23 pretty.Println("Hello World")24}25import (26func main() {27 fmt.Println("Hello World")28 log.Println("Hello World")29 pretty.Println("Hello World")30}31import (32func main() {33 fmt.Println("Hello World")34 log.Println("Hello World")35 pretty.Println("Hello World")36}37import (38func main() {39 fmt.Println("Hello World")40 log.Println("Hello World")41 pretty.Println("Hello World")42}43import (44func main() {45 fmt.Println("Hello World")46 log.Println("Hello World")47 pretty.Println("Hello World")48}49import (

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4 log.Println("Hello World")5}6import (7func main() {8 fmt.Println("Hello World")9 log.Println("Hello World")10 log.SetFlags(0)11 log.Println("Hello World")12}13import (14func main() {15 fmt.Println("Hello World")16 log.Println("Hello World")17 log.SetFlags(0)18 log.Println("Hello World")19 log.SetPrefix("Prefix")20 log.Println("Hello World")21}

Full Screen

Full Screen

log

Using AI Code Generation

copy

Full Screen

1import "log"2func main() {3log.Println("hello world")4}5import "log"6func main() {7log.Println("hello world")8log.Panicln("hello world")9}10log.Panicln(0xc42004bf70, 0x1, 0x1)11main.main()12import "log"13func main() {14log.Println("hello world")15log.Panicln("hello world")16log.Println("hello world")17}18log.Panicln(0xc42004bf70, 0x1, 0x1)19main.main()20import "log"21func main() {22log.Println("hello world")23log.Panicln("hello world")24log.Println("hello world")25log.Fatalln("hello world")26log.Println("hello world")27}28log.Panicln(0xc42004bf70, 0x1, 0x1)29main.main()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful