Re: [go-nuts] Re: appengine golang logs

2017-11-03 Thread Sankar P
I knew about this package. I mentioned about this in my mail itself :-)

I wanted a different way as it is not always possible to replace "log"
calls in all the existing code. Some libraries need to be used in binaries
which will be deployed outside appengine. They should not have a dependency
on appengine libraries ideally.


2017-11-03 23:01 GMT+05:30 Jim Cote :

> In appengine you have to use google.golang.org/appengine/log package.
> The log calls must have a context passed to it.
>
> See https://cloud.google.com/appengine/docs/standard/go/logs/reference.
>
>
> On Friday, November 3, 2017 at 3:58:34 AM UTC-4, Sankar wrote:
>>
>> Hi
>>
>>
>> I have a golang file where I have code like:
>>
>>
>> log.Fatal("My error message: ", err)
>>
>>
>> When the above statement is executed, In the appengine logviewer, I get
>> something like:
>>
>> panic: os.Exit called goroutine 1 [running]:
>> os.Exit(0x1)
>> go/src/os/proc.go:58
>> 
>> +0x7c log.Fatal(0xc008549f60, 0x2, 0x2)
>> go/src/log/log.go:303
>> 
>> +0x79 main.main()
>> main.go:42
>> 
>> +0x201
>>
>> But I dont get any error message. The main.go:42 corresponds to the
>> log.Fatal line in my code but I do not get to see the error message that is
>> printed as part of the log statement.
>>
>> I see that appengine package has a "Log" function which may print the
>> AppLogs such that they can be viewed from the Google Appengine log console
>> itself.
>>
>> My question is, can the golang default log package be somehow instructed
>> to redirect to appengine ? Something like:
>>
>> if env == "AppEngine" {
>>   log.SetOutput(appengine.DefaultLogger)
>> }
>>
>> in my main file ? This way, I get to make my code not locked to google
>> cloud and also can deploy existing code which uses log already.
>>
>> Any pointers ?
>>
>> Thanks.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/XbhcR5eFdno/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Sankar P
http://psankar.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: appengine golang logs

2017-11-03 Thread Tamás Gulácsi
Use log.SetWriter to divert log calls to appenginelog, if deployed there.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: appengine golang logs

2017-11-04 Thread Sankar P
There is no log.SetWriter in either the builtin log package or the
appengine log package. There is a log.SetOutput which I mentioned in my
original mail, but I am not able to understand how to connect it to the
appengine logs.

2017-11-04 11:44 GMT+05:30 Tamás Gulácsi :

> Use log.SetWriter to divert log calls to appenginelog, if deployed there.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/XbhcR5eFdno/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Sankar P
http://psankar.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: appengine golang logs

2017-11-04 Thread Gulácsi Tamás
Sth. along https://play.golang.org/p/BwlbkxMLdw ?

Sankar P  ezt írta (időpont: 2017. nov. 4.,
Szo, 8:10):

> There is no log.SetWriter in either the builtin log package or the
> appengine log package. There is a log.SetOutput which I mentioned in my
> original mail, but I am not able to understand how to connect it to the
> appengine logs.
>
> 2017-11-04 11:44 GMT+05:30 Tamás Gulácsi :
>
>> Use log.SetWriter to divert log calls to appenginelog, if deployed there.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/golang-nuts/XbhcR5eFdno/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Sankar P
> http://psankar.blogspot.com
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: appengine golang logs

2017-11-04 Thread Sankar P
Tried something similar already.

context.Background() does not work with the appengine log package and
panics at runtime. Passing nil also did not work.

Probably initialising the AELogAdapter with a ctx from appengine request,
in the _ah start handler is the only way. Thanks for the idea.

I, for one, though wish that there was a simpler way.

2017-11-04 12:47 GMT+05:30 Gulácsi Tamás :

> Sth. along https://play.golang.org/p/BwlbkxMLdw ?
>
> Sankar P  ezt írta (időpont: 2017. nov. 4.,
> Szo, 8:10):
>
>> There is no log.SetWriter in either the builtin log package or the
>> appengine log package. There is a log.SetOutput which I mentioned in my
>> original mail, but I am not able to understand how to connect it to the
>> appengine logs.
>>
>> 2017-11-04 11:44 GMT+05:30 Tamás Gulácsi :
>>
>>> Use log.SetWriter to divert log calls to appenginelog, if deployed there.
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "golang-nuts" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/golang-nuts/XbhcR5eFdno/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> golang-nuts+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Sankar P
>> http://psankar.blogspot.com
>>
>


-- 
Sankar P
http://psankar.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: appengine golang logs

2017-11-04 Thread David Arroyo
Sankar,

Have you tried using the Flexible environment? Flex provides a more
"conventional" environment for your programs. There are some
tradeoffs compared with App Engine Standard, but it should be easier
to stay portable.
David

[1]: 
https://cloud.google.com/appengine/docs/flexible/go/writing-application-logs

On Sat, Nov 4, 2017, at 03:26 AM, Sankar P wrote:
> Tried something similar already. 
> 
> context.Background() does not work with the appengine log package and
> panics at runtime. Passing nil also did not work.> 
> Probably initialising the AELogAdapter with a ctx from appengine
> request, in the _ah start handler is the only way. Thanks for
> the idea.> 
> I, for one, though wish that there was a simpler way. 
> 
> 2017-11-04 12:47 GMT+05:30 Gulácsi Tamás :
>> Sth. along https://play.golang.org/p/BwlbkxMLdw ?
>> 
>> Sankar P  ezt írta (időpont: 2017. nov.
>> 4., Szo, 8:10):>>> There is no log.SetWriter in either the builtin log 
>> package or the
>>> appengine log package. There is a log.SetOutput which I mentioned in
>>> my original mail, but I am not able to understand how to connect it
>>> to the appengine logs.>>> 
>>> 2017-11-04 11:44 GMT+05:30 Tamás Gulácsi :
 Use log.SetWriter to divert log calls to appenginelog, if deployed
 there. 
 
 --
  You received this message because you are subscribed to a topic in
  the Google Groups "golang-nuts" group.  To unsubscribe from this 
 topic, visit
  
 https://groups.google.com/d/topic/golang-nuts/XbhcR5eFdno/unsubscribe. 
  To unsubscribe from this group and all its topics, send an email
  to golang-nuts+unsubscr...@googlegroups.com[1].  For more options, 
 visit https://groups.google.com/d/optout.
>>> 
>>> 
>>> 
>>> -- 
>>> Sankar P
>>> http://psankar.blogspot.com
> 
> 
> 
> -- 
> Sankar P
> http://psankar.blogspot.com
> 


> --
>  You received this message because you are subscribed to the Google
>  Groups "golang-nuts" group.>  To unsubscribe from this group and stop 
> receiving emails from it,
>  send an email to golang-nuts+unsubscr...@googlegroups.com.>  For more 
> options, visit https://groups.google.com/d/optout.


Links:

  1. mailto:golang-nuts%2bunsubscr...@googlegroups.com

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: appengine golang logs

2017-11-04 Thread Sankar P
Thanks. I did not know this. I assumed that the only difference between
flexible and standard was the pricing, I was wrong. Thanks for the link.

2017-11-04 13:06 GMT+05:30 David Arroyo :

> Sankar,
>
> Have you tried using the Flexible environment? Flex provides a more
> "conventional" environment for your programs. There are some tradeoffs
> compared with App Engine Standard, but it should be easier to stay portable.
>
> David
>
> [1]: https://cloud.google.com/appengine/docs/flexible/go/
> writing-application-logs
>
>
> On Sat, Nov 4, 2017, at 03:26 AM, Sankar P wrote:
>
> Tried something similar already.
>
> context.Background() does not work with the appengine log package and
> panics at runtime. Passing nil also did not work.
>
> Probably initialising the AELogAdapter with a ctx from appengine request,
> in the _ah start handler is the only way. Thanks for the idea.
>
> I, for one, though wish that there was a simpler way.
>
> 2017-11-04 12:47 GMT+05:30 Gulácsi Tamás :
>
> Sth. along https://play.golang.org/p/BwlbkxMLdw ?
>
> Sankar P  ezt írta (időpont: 2017. nov. 4.,
> Szo, 8:10):
>
> There is no log.SetWriter in either the builtin log package or the
> appengine log package. There is a log.SetOutput which I mentioned in my
> original mail, but I am not able to understand how to connect it to the
> appengine logs.
>
> 2017-11-04 11:44 GMT+05:30 Tamás Gulácsi :
>
> Use log.SetWriter to divert log calls to appenginelog, if deployed there.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/golang-nuts/XbhcR5eFdno/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Sankar P
> http://psankar.blogspot.com
>
>
>
>
> --
> Sankar P
> http://psankar.blogspot.com
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/XbhcR5eFdno/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Sankar P
http://psankar.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.