本文整理汇总了Golang中github.com/grafana/grafana/pkg/log.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: AddOrgUser
func AddOrgUser(cmd *m.AddOrgUserCommand) error {
return inTransaction(func(sess *xorm.Session) error {
logger := log.New("main")
logger.Info(" AddOrgInvite3")
// check if user exists
if res, err := sess.Query("SELECT 1 from org_user WHERE org_id=? and user_id=?", cmd.OrgId, cmd.UserId); err != nil {
return err
} else if len(res) == 1 {
return m.ErrOrgUserAlreadyAdded
}
if res, err := sess.Query("SELECT 1 from org WHERE id=?", cmd.OrgId); err != nil {
return err
} else if len(res) != 1 {
return m.ErrOrgNotFound
}
logger1 := log.New("main")
logger1.Info(" AddOrgInvite4")
entity := m.OrgUser{
OrgId: cmd.OrgId,
UserId: cmd.UserId,
Role: cmd.Role,
Created: time.Now(),
Updated: time.Now(),
}
_, err := sess.Insert(&entity)
return err
})
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:30,代码来源:org_users.go
示例2: GetContextHandler
func GetContextHandler() macaron.Handler {
return func(c *macaron.Context) {
ctx := &Context{
Context: c,
SignedInUser: &m.SignedInUser{},
Session: GetSession(),
IsSignedIn: false,
AllowAnonymous: false,
Logger: log.New("context"),
}
// the order in which these are tested are important
// look for api key in Authorization header first
// then init session and look for userId in session
// then look for api key in session (special case for render calls via api)
// then test if anonymous access is enabled
if initContextWithRenderAuth(ctx) ||
initContextWithApiKey(ctx) ||
initContextWithBasicAuth(ctx) ||
initContextWithAuthProxy(ctx) ||
initContextWithUserSessionCookie(ctx) ||
initContextWithAnonymousUser(ctx) {
}
ctx.Logger = log.New("context", "userId", ctx.UserId, "orgId", ctx.OrgId, "uname", ctx.Login)
ctx.Data["ctx"] = ctx
c.Map(ctx)
}
}
开发者ID:mapr,项目名称:grafana,代码行数:30,代码来源:middleware.go
示例3: AddOrgInvite
func AddOrgInvite(c *middleware.Context, inviteDto dtos.AddInviteForm) Response {
logger := log.New("main")
logger.Info(" AddOrgInvite1", c.OrgId)
if !inviteDto.Role.IsValid() {
return ApiError(400, "Invalid role specified", nil)
}
// first try get existing user
userQuery := m.GetUserByLoginQuery{LoginOrEmail: inviteDto.LoginOrEmail}
if err := bus.Dispatch(&userQuery); err != nil {
if err != m.ErrUserNotFound {
return ApiError(500, "Failed to query db for existing user check", err)
}
} else {
return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto)
}
logger1 := log.New("main")
logger1.Info(" AddOrgInvite2", c.OrgId)
cmd := m.CreateTempUserCommand{}
cmd.OrgId = c.OrgId
cmd.Email = inviteDto.LoginOrEmail
cmd.Name = inviteDto.Name
cmd.Status = m.TmpUserInvitePending
cmd.InvitedByUserId = c.UserId
cmd.Code = util.GetRandomString(30)
cmd.Role = inviteDto.Role
cmd.RemoteAddr = c.Req.RemoteAddr
if err := bus.Dispatch(&cmd); err != nil {
return ApiError(500, "Failed to save invite to database", err)
}
// send invite email
if !inviteDto.SkipEmails && util.IsEmail(inviteDto.LoginOrEmail) {
emailCmd := m.SendEmailCommand{
To: []string{inviteDto.LoginOrEmail},
Template: "new_user_invite.html",
Data: map[string]interface{}{
"Name": util.StringsFallback2(cmd.Name, cmd.Email),
"OrgName": c.OrgName,
"Email": c.Email,
"LinkUrl": setting.ToAbsUrl("invite/" + cmd.Code),
"InvitedBy": util.StringsFallback3(c.Name, c.Email, c.Login),
},
}
if err := bus.Dispatch(&emailCmd); err != nil {
return ApiError(500, "Failed to send email invite", err)
}
return ApiSuccess(fmt.Sprintf("Sent invite to %s", inviteDto.LoginOrEmail))
}
return ApiSuccess(fmt.Sprintf("Created invite for %s", inviteDto.LoginOrEmail))
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:55,代码来源:org_invite.go
示例4: UpdateSubProcess
func UpdateSubProcess(cmd *m.UpdateSubProcessCommand) error {
return inTransaction2(func(sess *session) error {
logger := log.New("main")
logger.Info("updatedProcess3 %s")
subprocess := m.SubProcess{
SubProcessId: cmd.SubProcessId,
ProcessName: cmd.ProcessName,
SubProcessName: cmd.SubProcessName,
UpdatedBy: cmd.UpdatedBy,
Updated: time.Now(),
}
logger.Info("updatedProcess4 %s")
if _, err := sess.Where("sub_process_id= ?", subprocess.SubProcessId).Update(&subprocess); err != nil {
return err
}
logger.Info("updatedProcess5 %s")
sess.publishAfterCommit(&events.SubProcessUpdated{
Timestamp: subprocess.Created,
SubProcessId: subprocess.SubProcessId,
SubProcessName: subprocess.SubProcessName,
ProcessName: subprocess.ProcessName,
UpdatedBy: subprocess.UpdatedBy,
})
return nil
})
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:29,代码来源:subprocess.go
示例5: UpdateOrgProcessForCurrentOrg
func UpdateOrgProcessForCurrentOrg(c *middleware.Context, cmd m.UpdateOrgProcessCommand) Response {
cmd.ProcessId = c.ParamsInt64(":processId")
logger := log.New("main")
logger.Info("updatedProcess1 %s")
return updateOrgProcessHelper(cmd)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:7,代码来源:process.go
示例6: startHttpServer
func (g *GrafanaServerImpl) startHttpServer() {
logger = log.New("http.server")
var err error
m := newMacaron()
api.Register(m)
listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
g.log.Info("Initializing HTTP Server", "address", listenAddr, "protocol", setting.Protocol, "subUrl", setting.AppSubUrl)
switch setting.Protocol {
case setting.HTTP:
err = http.ListenAndServe(listenAddr, m)
case setting.HTTPS:
err = ListenAndServeTLS(listenAddr, setting.CertFile, setting.KeyFile, m)
default:
g.log.Error("Invalid protocol", "protocol", setting.Protocol)
g.Shutdown(1, "Startup failed")
}
if err != nil {
g.log.Error("Fail to start server", "error", err)
g.Shutdown(1, "Startup failed")
return
}
}
开发者ID:wk66,项目名称:grafana,代码行数:26,代码来源:server.go
示例7: StartServer
func StartServer() int {
logger = log.New("server")
var err error
m := newMacaron()
api.Register(m)
listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
logger.Info("Server Listening", "address", listenAddr, "protocol", setting.Protocol, "subUrl", setting.AppSubUrl)
switch setting.Protocol {
case setting.HTTP:
err = http.ListenAndServe(listenAddr, m)
case setting.HTTPS:
err = http.ListenAndServeTLS(listenAddr, setting.CertFile, setting.KeyFile, m)
default:
logger.Error("Invalid protocol", "protocol", setting.Protocol)
return 1
}
if err != nil {
logger.Error("Fail to start server", "error", err)
return 1
}
return 0
}
开发者ID:roman-vynar,项目名称:grafana,代码行数:26,代码来源:web.go
示例8: UpdateMachine
func UpdateMachine(cmd *m.UpdateMachineCommand) error {
return inTransaction2(func(sess *session) error {
logger := log.New("main")
logger.Info("updatedProcess3 %s")
machine := m.Machine{
MachineId: cmd.MachineId,
MachineName: cmd.MachineName,
Description: cmd.Description,
UpdatedBy: cmd.UpdatedBy,
Updated: time.Now(),
Vendor: cmd.Vendor,
}
logger.Info("updatedProcess4 %s")
if _, err := sess.Where("machine_id= ?", machine.MachineId).Update(&machine); err != nil {
return err
}
logger.Info("updatedProcess5 %s")
sess.publishAfterCommit(&events.MachineUpdated{
Timestamp: machine.Created,
MachineId: machine.MachineId,
MachineName: machine.MachineName,
Description: machine.Description,
UpdatedBy: machine.UpdatedBy,
Vendor: machine.Vendor,
})
return nil
})
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:32,代码来源:machine.go
示例9: GetPendingAlertActionHistory
func GetPendingAlertActionHistory(c *middleware.Context) Response {
logger := log.New("main")
logger.Info("GetMachine123 %s")
alertId := c.ParamsInt64(":id")
return GetPendingAlertActionHistoryHelper(alertId)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:7,代码来源:alert_history.go
示例10: UpdateMaintenance
func UpdateMaintenance(cmd *m.UpdateMaintenanceCommand) error {
return inTransaction2(func(sess *session) error {
logger := log.New("main")
logger.Info("updatedProcess3 %s")
maintenance := m.Maintenance{
Id: cmd.Id,
Component: cmd.Component,
Parameter: cmd.Parameter,
Message: cmd.Message,
Interval: cmd.Interval,
}
logger.Info("updatedProcess4 %s")
if _, err := sess.Where("Id= ?", maintenance.Id).Update(&maintenance); err != nil {
return err
}
logger.Info("updatedProcess5 %s")
sess.publishAfterCommit(&events.MaintenanceUpdated{
Timestamp: time.Now(),
Id: maintenance.Id,
Component: maintenance.Component,
Parameter: maintenance.Parameter,
Message: maintenance.Message,
Interval: maintenance.Interval,
})
return nil
})
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:31,代码来源:Maintenance.go
示例11: GetMaintenacneById
func GetMaintenacneById(c *middleware.Context) Response {
logger := log.New("main")
logger.Info("GetMachine123 %s")
Id := c.ParamsInt64(":Id")
return getMaintenanceUserProfile(Id)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:7,代码来源:Maintenance.go
示例12: AddMachineToCurrentOrg
// POST /api/process
func AddMachineToCurrentOrg(c *middleware.Context, cmd m.AddMachineCommand) Response {
logger := log.New("main")
logger.Info("Add ProcessForCurrentOrg", c.OrgId)
cmd.OrgId = c.OrgId
return addMachineHelper(cmd)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:8,代码来源:machine.go
示例13: NewDashAlertExtractor
func NewDashAlertExtractor(dash *m.Dashboard, orgId int64) *DashAlertExtractor {
return &DashAlertExtractor{
Dash: dash,
OrgId: orgId,
log: log.New("alerting.extractor"),
}
}
开发者ID:roman-vynar,项目名称:grafana,代码行数:7,代码来源:extractor.go
示例14: GetSubProcessByName
func GetSubProcessByName(c *middleware.Context) Response {
logger := log.New("main")
logger.Info("Get Sub Process1 %s")
processName := c.Params(":processName")
logger.Info("Get Sub Process 2 %s", processName)
return getSubProcessProfile(processName)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:7,代码来源:sub_process.go
示例15: GetSubProcessById
func GetSubProcessById(c *middleware.Context) Response {
logger := log.New("main")
logger.Info("GetProcess123 %s")
subprocessId := c.ParamsInt64(":subProcessId")
logger.Info("GetProcess123 %s", subprocessId)
return getSubProcessUserProfile(subprocessId)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:7,代码来源:sub_process.go
示例16: RemoveOrgProcess
// DELETE /api/orgs/:orgId/users/:userId
func RemoveOrgProcess(c *middleware.Context) Response {
logger := log.New("main")
logger.Info("GetProcess", c.ParamsInt64(":process_id"))
processId := c.ParamsInt64(":process_id")
orgId := c.ParamsInt64(":orgId")
return removeOrgProcessHelper(orgId, processId)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:8,代码来源:process.go
示例17: NewRuleReader
func NewRuleReader() *DefaultRuleReader {
ruleReader := &DefaultRuleReader{
log: log.New("alerting.ruleReader"),
}
go ruleReader.initReader()
return ruleReader
}
开发者ID:yuvaraj951,项目名称:grafana,代码行数:8,代码来源:reader.go
示例18: NewApiClient
func NewApiClient(httpClient *http.Client, datasource *models.DataSource) *apiClient {
return &apiClient{
DataSource: datasource,
log: log.New("tsdb.mqe"),
httpClient: httpClient,
responseParser: NewResponseParser(),
}
}
开发者ID:mapr,项目名称:grafana,代码行数:8,代码来源:httpClient.go
示例19: NewS3Uploader
func NewS3Uploader(bucket, accessKey, secretKey string) *S3Uploader {
return &S3Uploader{
bucket: bucket,
accessKey: accessKey,
secretKey: secretKey,
log: log.New("s3uploader"),
}
}
开发者ID:roman-vynar,项目名称:grafana,代码行数:8,代码来源:s3uploader.go
示例20: NewMigrator
func NewMigrator(engine *xorm.Engine) *Migrator {
mg := &Migrator{}
mg.x = engine
mg.Logger = log.New("migrator")
mg.migrations = make([]Migration, 0)
mg.dialect = NewDialect(mg.x.DriverName())
return mg
}
开发者ID:linkslice,项目名称:grafana,代码行数:8,代码来源:migrator.go
注:本文中的github.com/grafana/grafana/pkg/log.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论